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

  • Topic Author
  • Posted (edited)

    Adding your own QA classes and map to HASS entities

     

    When declaring your own classes it can either be done in the Config file of the main HASS QA, but it is recommended to create a new QA file and define a module function

    Please login or register to see this code.

    It should be named MODULE_<name>, and the name should be alphabetically be greater then 'MODULE_0classes' as the base classes are defined in that module.
    In any case, this is a file (together with the Config file) that you want to save in case you need to update the HASS QA in the future, because it's not part of my standard HASS QA.

    However, if you make a good QA class that can be useful for others I'm happy to add it to the base classes defined, so it becomes a part of the standard HASS QA. Credits due.

     

    Ok, assume that we have a HASS climate entity that represents a hvac system. We want to create com.fibaro.temperatureSensor child QAs for the entity's attribute .current_temperature. A way to keep an eye on the temp in HC3 and maybe create scenes that trigger when temperature has certain values....

     

    First we define the class
     

    Please login or register to see this code.

    All classes inherits from 'HASSChild'

     

    The important part here is the :update(entity) function.

    It will be called whenever the HASS entity that this QA instance subscribes to changes state.

    Here we expect the entity to have an attribute .current_temperature . It's a good practice to code defensively if there is no such attribute. The user may have associated the QA with an entity that doesn't have that attribute...

     

    The lua object Entity that is the argument to update contains .state and .attributes from the HASS entity,

    It also has a .type that is the type being assigned to this entity. See first post.

    We can use that in :update to check that the entity we get is something that we understand...

    However, per default the hvac entities we look for is of HASS entity type 'climate' and there can be other climate entities that are not hvac systems. How can we recognize them?  We can give them a custom mapping.

    Please login or register to see this code.

    Here we say, if the HASS entity_id starts with 'climate.' we call the function that determines if the entity has  .hvac_modes and .current_temperature attributes. Is so we return (give it) the  entity type 'climate_hvac'. 

     

    Now we have a couple of different choices for how to create QAs for these entities.

     

    1. We can say that all entities that we have typed 'climate_hvac' should be instantiated as child QAs of class 'CurrTemperature'

    Please login or register to see this code.

     

    2. We can also in the HASS QAs UI select the CurrTemperature class and assign it a specific entity_id and create QA.

     

    3. We can do a specific mapping.

    Please login or register to see this code.

    The HASS.classes.CurrTemperature.qa is a list of QAs we want to create if they don't exists.

    The way we know if the QAs exists is the unique id (uuid) that we give each QA, the key 'currTemp_1' in this example. We could define more QAs with other unique IDs also.

    The entities list is the specific HASS entity_ids we want to assign the QA. Here it's just one entity, but some QAs accept more than one entity. Ex. we could assign a battery sensor entity_id to give the QA a batteryLevel property...

     

    Now, we may want to create a binary sensor that is true if the hvacs attribute .current_teperature is greater than the attribute  .temperature

     

    Register the class

    Please login or register to see this code.

    This tells that the QA child class MyBinarySensor  when created should be of type com.fibaro.binarySensor

    The you define the class

    Please login or register to see this code.

    and then we autocreate  these QAs

    Please login or register to see this code.

    It's no problem that we have previously create CurrTemperature QAs for the same 'climate_hvac' entities, because QAs can share HASS entities - they "subscribe" to the same HASS entities.

    Edited by jgab
    Posted (edited)

    Hello

    i played with the QA but not able to add childs devices and especially i would like to control my heat pump

    entity is the following " climate"

    climate.maison_nantes_zone_etage_circuit_2_climate

    selected THERMOSTAT as class

    child device is create but it is empty.

     

    i m not sure to know how to solve this ?

     

    Please login or register to see this attachment.

    Result :

    Please login or register to see this attachment.

     

     

     

    Edit : I added not only 1 entity but 3 (climate + current +  desired temp)

    result  = Now i'm able to see thermostat mode (Comfort , Eco, Auto) but no impact on the HASS device

    Please login or register to see this image.

    /monthly_2025_01/Capturedecran2025-01-18a14_45_55.png.ee1816693d46ea31c823c316a7e73dde.png" />

     

    Edited by SakkhhoID
  • Topic Author
  • Posted

    Ok, the Thermostat class is not fully implemented  - there are no actions implemented yet.

    The problem is that I don't have any Thermostat myself so I can't develop and test...

    A device like a heat pump in HASS, is usually implemented as several entities, a hvac, temperatures, and maybe buttons.

    Depending on features it can make it difficult to fit it completely into the fibaro.com.thermostat type and interface.

     

    But let's see if we can get the hvac modes set correctly. Can you post the YAML for the 

    climate.maison_nantes_zone_etage_circuit_2_climate (and related entities) ?

    Usually you can see them in the developer tools menu when you look at the state of an entity

    Posted (edited)

    Hello

    Should be this one

     

    Please login or register to see this code.

     

    Surprisingly the calendar data are wrong, nothing to do with my heating program. But what i would like to control is only the heating mode (Confort, Eco, none) and the setting temperature.

     

    and how it is implemented in HASS

    Please login or register to see this image.

    /monthly_2025_01/Capturedecran2025-01-19a10_12_09.png.e31354c85bc814c535a668efaf79fc5f.png" />

     

    Thks a lot , and huge congrats for these 1st versions; PROMISING !!

    Edited by SakkhhoID
  • Topic Author
  • Posted (edited)
    4 hours ago, SakkhhoID said:

    Hello

    Should be this one

     

    Surprisingly the calendar data are wrong, nothing to do with my heating program. But what i would like to control is only the heating mode (Confort, Eco, none) and the setting temperature.

     

    and how it is implemented in HASS

     

     

    Thks a lot , and huge congrats for these 1st versions; PROMISING !!

     

    I attached v0.72 in the first post. It fixes some other problems but have a little bit better implementation of Thermostat (I hope).

    You need to enable it in Config but uncomment the line

    Please login or register to see this code.

     

    Edited by jgab
    • Like 1
    Posted (edited)

    Hello

    the changes are important or we can do the changes manually ? (in order to avoid to import a new QA and create all Childs with new IDs) ?

     

    if not that big, can you post the code ?

     

    edit

    forget it , i restored a backup on my HC3 in order to reimport the QA 

    Edited by SakkhhoID
    Posted (edited)

    Now it works  ! WOW =

     

    i'm able to manage change the preset mode. will continue to play with the QA

    Please login or register to see this attachment.

     

     

    One question, i have lot of childs devices created (and useless for the moment), how to control the creation of childs devices during the 1st syncro ?

    especially, UNIFI entities and others.

     

    Seconde question

    the hot water entity should be also mapped as a thermostat  no ?

    Please login or register to see this code.

     

    Please login or register to see this code.

     

     

     

    regards

     

    Edited by SakkhhoID
  • Topic Author
  • Posted
    51 minutes ago, SakkhhoID said:

    Now it works  !

     

    i'm able to manage change the preset mode. will continue to play with the QA

     

    One question, i have lot of childs devices created (and useless for the moment), how to control the creation of childs devices during the 1st syncro ?

    especially, UNIFI entities and others.

     

    Seconde question

    the hot water entity should be also mapped as a thermostat  no ?

    Please login or register to see this code.

     

    regards

     

     

    In the Config file of the QA you can comment out the 

    HASS.class.X.auto='Y'

    that automatically generates child devices for specific types. If you comment them out you can delete the child/children in the UI and they will not be recreated when the QA restarts.

    The hot water entity seems to be a slightly different animal, and can not use the existing Thermostat class.

    Posted

    indeed i commented out the HASS.class and kept for the time being only the 3 thermostats i need.

    it will be great, instead of automatic creation of all "entities" in HASS that we will be able to accept or not the child devices ?

     

    however, thank you very much, for your work 

  • Topic Author
  • Posted
    3 minutes ago, SakkhhoID said:

    indeed i commented out the HASS.class and kept for the time being only the 3 thermostats i need.

    it will be great, instead of automatic creation of all "entities" in HASS that we will be able to accept or not the child devices ?

     

    however, thank you very much, for your work 

    Yes, the idea is that you do that by configuring the Config file.

    To manually add each device you want in the UI is to cumbersome if you have many devices.

    Posted (edited)

    it is true, but my UNIFI integration = 11 devices and 156 entites ... :-)

    most of them as useless, and should be added in a Big QA and not as sensor & co.

     

    i prefer to keep my HC3 'clean' interface by selecting manually devices i would like to add.

     

     

    is it still possible to add sensor i guess even if i have commeted out the line in config right ?

     

     

     

    Edited by SakkhhoID
  • Topic Author
  • Posted
    56 minutes ago, SakkhhoID said:

    is it still possible to add sensor i guess even if i have commeted out the line in config right ?

    Yes

     

     

    • Like 1
    Posted (edited)

    @jgab

     

    if i'm moving the thermostat from the default room (where it is created) to a HC3 room , i'm lossing the preset mode

    Please login or register to see this image.

    /monthly_2025_01/Capturedecran2025-01-19a17_52_18.png.a02b8e3a5587307a0149a283af1ebe45.png" />

    nothing under 'SELECT '

     

    originally i have

     

    Capturedecran2025-01-19a17_46_31.png.7f77eb2544514f2a4f6179134a27de73.png

     

    if i'm moving back the thermostart to DEFAULT room, still the same bug

    if i re-sync, same

     

    Edited by SakkhhoID
  • Topic Author
  • Posted
    3 minutes ago, SakkhhoID said:

    @jgab

     

    if i'm moving the thermostat from the default room (where it is created) to a HC3 room , i'm lossing the preset mode

    Please login or register to see this link.

    nothing under 'SELECT '

     

    originally i have

    Shouldn't affect the presets. Could be a bug with the Fibaro drop down that shows up. Try to flip between some UI tabs or click on another QA and back to the Thermostat.

    Sometimes a reload of the web page does it...

    Posted

    ok, the only thing to solve this is to restart the HC3 ... 

    Posted

    Hello @jgab

    how can i add the hot water entity ?

    i would like to be able to change the temperature once a month for legionella treatment. 

    there is a legionella mode in my system but not in MYVAILLANT app so i think i can activate it through HA. Only solution is Once a month to set up the temp @60c and back to normal temp the day after

    tks 

    • 1 month later...
    Posted

    @jgab

     

    QA cannot connect to HASS over duckdns. Can you please help?

    [17.03.2025] [13:50:00] [DEBUG] [QUICKAPP1286]: HASS v:0.72

    [17.03.2025] [13:50:00] [DEBUG] [QUICKAPP1286]: Websocket connect

    [17.03.2025] [13:50:00] [DEBUG] [QUICKAPP1286]: Connect: ws://XXXXXXXXX.duckdns.org:XXXXX/api/websocket

    [17.03.2025] [13:50:04] [ERROR] [QUICKAPP1286]: Error: Connection failed

  • Topic Author
  • Posted

    You are connecting remotely, from another network?

    I don't think that works...

    Then I assume you would need wss: and have the certictificates that HASS sets up.

    It may be the that the HASS app uses wss: to connect but I don't know.

    • 1 month later...
    Posted (edited)

    To add cover (this is the HASS term, roller-shutter in fibaro) I see already jgab put in the 'Cover' class. I just enabled it by adding this in config:

     

    customerType:

     

      HASS.customTypes['^cover%.'] = function(e)
            if e.attributes.current_position and e.attributes.device_class=='awning' then return 'roller_awning'
            elseif e.attributes.current_position and e.attributes.device_class=='shutter' then return 'roller_shutter'
            elseif e.attributes.current_position and e.attributes.device_class=='window' then return 'roller_window' end
      end
     
    Then by adding at the bottom evaluation:
     
        HASS.classes.Cover.auto={                   -- Define all door Cover types as Shutter
        'roller_awning',
        'roller_shutter',
        'roller_window'
        }
     
    This worked out of the box. Integration back and forth from either HC3 or HASS do their magic.
     

    Please login or register to see this image.

    /monthly_2025_04/image.png.fb5f76342b56e15902eef0efa633df5a.png" />
     
    image.png.c1bbd6690f1de69033d5e4d43733e00f.png
     
    Really loving this integration!!
     
     
     

    And i think i have another addon thats not for everybody: getting all temperature sensors that HASS has to fibaro, you'd need to add this to a seperate file in the QA, like 'CUSTOM'  or 'USER' 

     

    -- Example of a user module, with own classes
    function MODULE_1classes()
     
        -- Your classes and filter, entityMappings, and auto markings
          HASS.customTypes['^climate%.'] = function(e)
            if e.attributes.hvac_modes and e.attributes.current_temperature then return 'climate_current_temp' end
          end
         
          HASS.classes.CurrTemperature = { -- Register CurrTemperature class in classes table
            type = 'com.fibaro.temperatureSensor',
          }
         
          HASS.classes.CurrTemperature.auto='climate_current_temp'-- Temperature from climate entities
         
          class 'CurrTemperature'(HASSChild)
          function CurrTemperature:__init(dev) HASSChild.__init(self,dev) end
          function CurrTemperature:update(entity)
            local attr = entity.attributes
            self:updateProperty("value", attr.current_temperature or 0) -- no attr, set 0
          end    
     
    end
     
    -- beware, that if you have Thermastat enabled, they will ' clash'  as in my example they have the same evaluation. I dont know how to work around this, it seems that the fibaro thermastat can only have desired values, not carrying current Temperature., just comment that part out in that case:
      -- HASS.customTypes['^climate%.'] = function(e)
      --   if e.attributes.hvac_modes then return 'climate_hvac' end
      -- end
     
     
    Edited by Danny Boy
    • Like 2
    • 7 months later...
    Posted

    Hi jgab

    I'm getting an error in the HASS Quick App.

    What do I need to fix?

     

    [2025-12-01] [11:07:26 PM] [DEBUG] [QUICKAPP2688]: Skipping update.smartthings_station_firmware
    [2025-12-01] [11:07:27 PM] [ERROR] [QUICKAPP2688]: loadExistingChildren:./quickApp.lua:56: attempt to compare number with function
    [2025-12-01] [11:07:27 PM] [ERROR] [QUICKAPP2688]: Callback error: ./include/main.lua:279: attempt to index a nil value (local 'c')

    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...