Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


Recommended Posts

Posted (edited)

This is a QA that helps bringing HASS devices into the HC3 as QAs. It's still under work...

The audience for this QA are people that have some understanding of HASS and coding QAs.


There are other QAs for HASS in the forum but this focus on being easy to code new integrations for.

There are a number of ready-made QA mappings already, so it can work "out-of-the-box" for many common HASS devices/entities. Some QA mappings are still under development, or I don't have the physical devices so I don't understand exactly how to do it, or I haven't prioritized it. Help here from the community is appreciated.

Git repo here 

Please login or register to see this link.


Easiest to develop with

Please login or register to see this link.

and the

Please login or register to see this link.

 

Please login or register to see this attachment.

v0.72

 

Please login or register to see this attachment.

 

3 variables to setup

Please login or register to see this attachment.

  • 'token' is the "Long-lived access tokens" from HASS (under profile/security)
  • 'url' is the IP:port of you HASS server
  • 'debug' are a comma separated list of debug flags that affect what is logged in the console.

 

To be able to map HASS entities to QA devices we need to identify the entity.  

HASS have the entity_id that looks like <domain>.<name> but the domain can contain different stuff. Some domains has an attributes.device_class that further specify the type of the entity. Ex. a temperature entity has domain = 'sensor' and attributes.device_class = 'temperature'

If an entity does not have a device_class it is possible to assign a device class to the entity in HASS.

 

The HASS QA will try to assign each entity that it fetches from the HASS server an 'type'. It does so by creating a type by concatenating domain and device_class so ex. a temperature sensor becomes the type 'sensor_temperature'. A media player of type speaker (like Sonos) gets type 'media_player_speaker' where media_player is the domain and speaker the device_class. If the entity lacks device_class the type is just the domain.

 

In the Config file of the HASS QA, we can then configure how the various HASS entities should be mapped to QAs given the type.

 

For some domains like 'light' we don't have a device_class so we don't know if the light is an rgb light or just a dimmable light. In Configure we can setup remapping of types for the entities we get from HASS.

Please login or register to see this code.

The customTypes table contains Lua pattern to match against the entity_id. In this case we match against the domain part of the entity_id and if it is 'light.' we call a function to determine what 'type' we should assign the entity. In this case we look at the entities attributes if it supports RGB or just brightness and return the according type. (Note if the function return nil, the entity keeps its default type)

 

We can also filter out entities we are not interested in

Please login or register to see this code.

Here the table key is a string path pointing at a key in the entity. 

In this example we ignore fibaro devices integrated in HASS...

 

There is a table HASS.classes that contains all QA classes we can map our entities to.

We can annotate that table with entities we want to automap

Please login or register to see this code.

Here ex, all entities of type 'sensor_temperature' will be mapped to the Temperature QA class at startup.

Please login or register to see this code.

Here we map several types to the common QA class DoorSensor (which is implemented as com.fibaro.doorSensor)

In the provided Config file there is a whole section of auto mappings that are conditionally commented out. Enable it by setting

Please login or register to see this code.

in the Config file, or set the quickVar variable 'auto' to 'true'

 

There are a couple of other settings in Config

Please login or register to see this code.

The first function is used to name created QAs. The name argument is the entity's descriptive name. Default is to add " (HASS)" to the name to make it obvious that it is a HASS device.

HASS.defaultRoom is the room created QAs should be placed in. Takes a room name or room id.
HASS.proposeBattery if true will try to find a matching battery entity and add it to the QA created.

 

There is also a UI where we can create QA mappings.

Please login or register to see this image.

/monthly_2025_01/image.png.c5f4610c5b45c05b3cc64258676fe6c0.png" />

The first drop down list all the child QAs we have installed. The first option, <New QA> is selected when a new QA should be created. If an existing QA is selected we can update the QA (assign new entities to it)
 

image.png.51c5f44b5ae9912d9285f1d4234ad593.png

The second drop down is the QA child classes we can select between.

 

 

image.png.4620b02f0d69c71514409c94336fd89b.png

The last drop down is all the entities, their type, name (part after domain in entity_id) and status.

This is a multi select so we can assign multiple entities to the QA we create.

 

Important. The first entity we chose will be the "main" entity of the QA. It will decide the name of the QA and is also used when searching for matching battery_entities.

 

If we assign an entity of type sensor_battery or sensor_energy to a QA, the the will implement the batter and/or the energy interface and update this properties automatically.

 

Current implemented QA classes
 

Please login or register to see this code.

 

Further topics: 

  • Config in-depth
  • Please login or register to see this link.

    • in-depth HASSChild class
  • HASS QA, callable methods
  • Notes on QA classes
    • Please login or register to see this link.

    • Calendar
    • DeviceTracker
    • ...

 

 

 

Please login or register to see this attachment.

Edited by jgab
  • Like 6
  • Thanks 1
  • Topic Author
  • Posted (edited)

    So, HASS is quite nice with the integrations they support. I have tried Hue and IKEA Dirigera + some virtual devices. I'm contemplating to maybe run my Hue/IKEA and some other integrations through HASS going forward. Now I have different QAs for Hue and IKEA that needs support - this way I would have only one api to support. + HASS has many other potential integrations. Why not move everything over to HASS? Well, I still have my automation (ER5) on HC3 and of course some zwave that I think works well on the HC3 and don't want to move to HASS.

    But of course it's also a way to hedge my bets if this platform doesn't survive, or can't keep up technically... 😉

    My HASS server runs on a PI 5, 8Gb under my bed at ~40° (also runs NodeRed)

    Please login or register to see this image.

    /monthly_2025_01/image.png.25a09b8bb58f1faa09cde91e50efa5a1.png" />

    Edited by jgab
    • Like 2
    Posted

    @Jgab,  mmmmhhh interesting. My HASS is shut down since 1,5 year because I did't see many advantages.

    Your remark for HUE/Ikea is interesting.

    I still have a PI4 and a NAS to run HASS.

    What I notice is some delay in switching light on or off as HC3 is in higher memory usage.

    HC3>>ER5>COH

    To replace COH with your alternative was't durable for me.

    Perhaps is what you suggest a solution certainly if the remote from HC3 can be  a trigger in HASS.

     

    Posted

    The remotes and all are triggers in HASS...

     

    slaapkamer hotel joyce turned off
    12:45:21 PM - Now
    slaapkamer 178.0 turned off
    12:45:20 PM - 1 second ago
     
     
    Going both ways from Fibaro to HASS (through this QA integration) is super quick, I'm not getting any delays.
    Other way around, from HASS to Fibaro i have the same experience.
     
    I like the dashboarding of HASS alot better than whats natively possible with Fibaro. 
     
    I'm running HC3 and hass on synology docker (but thinking of getting it natively and have zigbee + integration out of the box)
    Posted (edited)

    I seem to get 1 'nil' entity . I only changed the config to ignore fibaro. Maybe somehow it therefore sees 1 nil entity?

     

    This way I think the childs get associated wrong:
     

    [15.01.2025] [13:09:34] [DEBUG] [QUICKAPP427]: [New QA]
    Type: com.fibaro.binarySensor
    Class: BinarySensor
    Entity1:  nil
    Entity2:  [binary_sensor:383080390217002219_001_bsh_common_status_localcontrolactive:off]

     

    Ofcourse i cant deselect the nil entity

    Please login or register to see this attachment.

     

    Maybe because I didnt update the default room yet. Let see. >>> update: no it keeps happening for me.

     

    Edited by Danny Boy
  • Topic Author
  • Posted

    Any errors in the log? Would be interesting to understand what entity causes it.
    Can you produce a list of all entity names on your HASS and PM me it? 
    I realize that I should implement a dump all entities button in the QA...

    3 hours ago, Danny Boy said:

    I seem to get 1 'nil' entity . I only changed the config to ignore fibaro. Maybe somehow it therefore sees 1 nil entity?

    The Config already did contain a skip entry for fibaro. What did you change? Thinking it can be some change to config I haven't anticipated...

  • Topic Author
  • Posted (edited)
    3 hours ago, Danny Boy said:

    I seem to get 1 'nil' entity . I only changed the config to ignore fibaro. Maybe somehow it therefore sees 1 nil entity

    It seems to be an entity_id in the drop down selector that doesn't exists anymore...

    Can you go into the main file on line 276-277 and make the changes

    Please login or register to see this code.

    e.g. add the use entity_id in the loop variable on line 276 and add "HASS.entities[entity_id] or entity_id" on line 277.

    Then we can see what entity_id that cause the problem.

    Did you press "Resync"? Think that can have problems if an entity is removed from HASS...

    Edited by jgab
    • Like 1
    Posted

    Jan can you confirm?

    rule([[@19:00 => remote(1204, #licht_bedroom_off)]])

    Just an example.

    Lets give example how I do it.

    A lamp is having different states and I execute this with post(#dining_lamps_Full), post(#dining_lamps_Normal),post(#dining_lamps_Dim), post(#dining_lamps_Min),post(#dining_lamps_Candle), post(#dining_lamps_Fire),post(#dining_lamps_Burgler)

    Some lamps get color set as extra order.

    Is this easy to send from HC3 into HASS?

  • Topic Author
  • Posted (edited)
    14 minutes ago, Sjakie said:

    Jan can you confirm?

    rule([[@19:00 => remote(1204, #licht_bedroom_off)]])

    Just an example.

    Lets give example how I do it.

    A lamp is having different states and I execute this with post(#dining_lamps_Full), post(#dining_lamps_Normal),post(#dining_lamps_Dim), post(#dining_lamps_Min),post(#dining_lamps_Candle), post(#dining_lamps_Fire),post(#dining_lamps_Burgler)

    Some lamps get color set as extra order.

    Is this easy to send from HC3 into HASS?

    Yes, it should work. The LightRGB classes are not fully developed yet, but setting RGB seems to work...

    Edited by jgab
  • Topic Author
  • Posted

    -------------------------------

     

    Attached v0.68 in the first post with updates, that hopefully fixes the nil entity issue that @Danny Boy had.

    Probably it was a bug with the automatic attachments of battery entities to QAs...

    • Like 2
    Posted

    It fixes it a little bit, i now see:

     

    [15.01.2025] [18:07:42] [TRACE] [QUICKAPP432]: UIEvent: {"elementName":"entitySelect","values":[["option3","automation.flock_of_lights_define_brightness"]],"deviceId":432,"eventType":"onToggled"}
    [15.01.2025] [18:07:42] [DEBUG] [QUICKAPP432]: [New QA]
    Type: [None]
    Class: [None]
    Entity1:  option3
    Entity2:  [automation:flock_of_lights_define_brightness:on]

     

    Does that make sense to you? It also auto created 20 children now :P. So something definitely changed

    Posted (edited)

    ok version 0.67 did't work

    0.68 created 75 child devices

    Please login or register to see this code.

    warning on all  devices.

    Should I create first rooms in HASS? Then sync?

    Edited by Sjakie
  • Topic Author
  • Posted
    19 minutes ago, Sjakie said:

    ok version 0.67 did't work

    0.68 created 75 child devices

    Please login or register to see this code.

    warning on all  devices.

    Should I create first rooms in HASS? Then sync?

    No, change the name of the room to what you want to put the devices in in Config file. It is set to "Default Room" per default. Set it to nil or some room you prefer. The warning is no harm, it will just place it in whatever room the QA gets created in.

    1 hour ago, Danny Boy said:

    It fixes it a little bit, i now see:

     

    [15.01.2025] [18:07:42] [TRACE] [QUICKAPP432]: UIEvent: {"elementName":"entitySelect","values":[["option3","automation.flock_of_lights_define_brightness"]],"deviceId":432,"eventType":"onToggled"}
    [15.01.2025] [18:07:42] [DEBUG] [QUICKAPP432]: [New QA]
    Type: [None]
    Class: [None]
    Entity1:  option3
    Entity2:  [automation:flock_of_lights_define_brightness:on]

     

    Does that make sense to you? It also auto created 20 children now :P. So something definitely changed

    Yes, this makes sense, the "option3" is a surprising bug that you uncovered :-) 
    Does the "option3" disappear when you change to other QAs and back?

  • Topic Author
  • Posted

    Attached v0.69 that fixes the annoying 'option3' bug.

    • Like 2
  • Topic Author
  • Posted

    v0.70 with more bug fixes...

    • Like 1
  • Topic Author
  • Posted (edited)

    v0.71, more bug fixes, forgot to ignore skipped entities that changed states.

    DeviceTracker updates quickvars with location, long, lat. Will see if it's feasible to update HC3 users' locations...

    Edited by jgab
    • Like 2
    Posted

    Nice one, this works flawlessly now. Very impressive!

    Posted
      HASS.classes.Co2.auto='sensor_carbon_dioxide'           -- Define all CO2 sensors as CO2
     
    added this in config and works great. Think I got the way its extendable, very easy.
    • Like 1
  • Topic Author
  • Posted (edited)

    Zone class

    The Zone class maps to the HASS entity zone. The entity_id is ex. 'zone.home' for the home zone.

    If positioning is setup for the mobile companion app for HASS, the zone entities will update when the phone's device_tracker is within the zone, or more specific, the person associated the phone.

    HASS has many other ways to inject positioning into the HASS system using the entity device_tracker, but I have found this to be pretty reliable.

     

    By mapping the zone entities to the QA child class Zone implemented as com.fibaro.binarySensor we get a simple (zone) presence detection in HC3

     

    In Config:
     

    Please login or register to see this code.

    We get the QA

    Please login or register to see this attachment.

    The sensor is true when someone is in the zone and false if no persons are within the zone.

    The QA's quickAppVariables will be populated with the persons being in the zone (true) and the persons not being in the zone (false)

    Please login or register to see this attachment.

    Edited by jgab
    • Like 1
  • Topic Author
  • Posted

    Calendar

     

    It's relatively easy to setup calendars in HASS, especially linked to Google calendar.

     

    The Calendar class maps to the HASS entity calendar. The entity_id is ex. 'calendar.<name>' for a specific calendar with name <name>

     

    By mapping the calendar entities to the QA child class Calendar implemented as com.fibaro.binarySensor we get a simple calendar QA in HC3

     

    In Config:

    Please login or register to see this code.

    We get the QA

    Please login or register to see this attachment.

     

    The sensor is true if there is an ongoing event and false otherwise,

    It also populates its quickVars with the current or future event data

     

    Please login or register to see this attachment.

     

    There is one more trick the Calendar class provides. If the event description contains the tag string

    Please login or register to see this code.

    it will post a HC3 customEvent with name and userDecsription at the time the event becomes true.

    Ex.  a calendar entry for Tuesdays at 08:00-08:30

    Please login or register to see this code.

    will post a customEvent at 08:00 with name 'trash' and userDescription "before eight o'clock".

     

    Assume that we want to get the event an hour before, so we have some time to act, we can add a before time to the tag

    Please login or register to see this code.

    will post a customEvent at 07:00 with name 'trash' and userDescription  "before eight o'clock".

    • Like 2

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Reply to this topic...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...