Announcement

Collapse
No announcement yet.

HomeAssistant Discovery

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    HomeAssistant Discovery

    Version 5.1.2.0 added the ability to recognize the advertisements made by devices using the HomeAssistant Discovery https://www.home-assistant.io/docs/mqtt/discovery/ mcsMQTT will collect the advertisements and if it sees a topic that matches something that has been advertised it will setup that device in HS automatically and use the pertinent information in the discovery disclosure to provide the appropriate user interface.

    All disclosures provided by Tasmota version 8.1 devices have been incorporated. There are parts of the HomeAssistant discovery API that are not implemented, but will be added as other devices that use this protocol have been identified. Just let me know what you have and include the messages where discovery is being advertised.

    Tasmota has done a reasonable disclosure for lighting, plugs, switches. I thought fan speed would be a something to advertise for a fan controller, but Tasmota only advertises the on/off control. It just means the "A"ssociate checkbox needs to be clicked in mcsMQTT to get the fan device and adding the publish topic to get the selector for the four speeds.

    Tasmota discovery protocol is enabled with "SetOption19 1" on the Tasmota console. In addition to the disclosure on topic homeassistant/+/+/config, a new topic +/HASS_STATE has been added and the disclosure on this topic is for the RSSI. This seemed to be odd as there are many WiFi attributes as well as other attributes reported periodically besides just this one.

    Auto HS device creation applies to the initial detection of a topic. If Tasmota device was run without SetOption19 set then mcsMQTT will see the topics and not create HS devices automatically because it had not previously observed a homeassistant/+/+/config topic that described its characteristics. To achieve auto device creation then select the Tasmota device topics for this device to be obsolete on either General tab with Obsolete wildcard in Inbound Management or from Association tab with the "O"bsolete column checkboxes. Restart the Tasmota device and auto device creation will occur.

    Updater image for the this version is at http://mcsSprinklers.com/mcsMQTT_5_1_2_0.zip

    #2
    Will this work for other firmware that advertise their capabilities?

    Comment


      #3
      Yes, but I only tested with Tasmota. If there is something that was implemented in other firmware but not Tasmota then let me know and I will add. While there is a definition for the convention there will be variances so I want to implement what is actually used and not make assumptions about how a device will actual employ the convention.

      Comment


        #4
        I have never used Tasmota and favor ESPHome at the moment. Not that I am requesting that you make any changed for ESPHome, just curious if it might work. I will give it a try.

        Thanks for all your efforts.

        Comment


          #5
          ESPHome supports MQTT discovery in Home Assistant so I am hoping it works.

          Comment


            #6
            I loaded esphome on my WIndows laptop following the tutorial at https://esphome.io/guides/getting_st...mand_line.html
            I had no problem loading a D1 mini and running it with feedback in the USB console.
            Click image for larger version

Name:	Capture.PNG
Views:	454
Size:	70.1 KB
ID:	1362851 The yaml file
            Code:
            esphome:
              name: livingroom
              platform: ESP8266
              board: d1_mini
            
            wifi:
              ssid: "Anthem"
              password: "???"
            
              # Enable fallback hotspot (captive portal) in case wifi connection fails
              ap:
                ssid: "Livingroom Fallback Hotspot"
                password: "LPNBb53uFhPf"
            
            captive_portal:
            
            # Enable logging
            logger:
            
            # Enable Home Assistant API
            api:
              password: "no"
            
            ota:
              password: "no"
            
            switch:
              - platform: gpio
                name: "Living Room Dehumidifier"
                pin: 5
            If I use browser to navigate to 192.168.0.164 I get a page not found response. How do you interact with the device that has esphome firmware?

            I do not see anywhere in the yaml file where the MQTT broker is identified. How do you setup MQTT with esphome?

            The tutorial setup a switch as an output which is in effect a relay. How do you tell esphome to toggle the switch/relay?

            Comment


              #7
              I am still learning ESPHome so I am by no means an expert.

              All the configuration for each ESPHome device is done in the YAML config file. Once you upload the config to the SOC via USB you can then use the dashboard to upload any changes via OTA. You don't connect to the device to configure it. There is a fallback hotspot that you can connect to if the device can't get to your WiFi network.

              Remove this. It configures ESPHone to use the native Home Assistant API.
              Code:
               
               # Enable Home Assistant API api:   password: "no"
              Here is what I have for the broker.

              Code:
              mqtt:
                broker: 192.168.x.x
                discovery: true
                username: mosquitto
                password: mosquitto


              Comment


                #8
                I kept reading and did find out how to get MQTT working with esphome and observed the discovery message with the pertinent parts below.
                Code:
                "state_topic":"livingroom/switch/living_room_dehumidifier/state",
                "command_topic":"livingroom/switch/living_room_dehumidifier/command",
                "availability_topic":"livingroom/status",
                For Tasmota one of the discovery messages is
                Code:
                                'homeassistant/sensor/CFB4C6_ENERGY_TotalStartTime/config=
                                '{"name":"Tasmota ENERGY TotalStartTime",
                                '"stat_t":"~SENSOR",
                                '"avty_t":"~LWT",
                                '"frc_upd":true,
                                '"pl_avail":"Online","pl_not_avail":"Offline",
                                '"uniq_id":"CFB4C6_ENERGY_TotalStartTime",
                                '"device":{"identifiers":["CFB4C6"],
                                '"connections":[["mac","DC:4F:22:CF:B4:C6"]]},
                                '"~":"SonoffS31/tele/",
                                '"unit_of_meas":" ",
                                '"val_tpl":"{{value_json['ENERGY'].TotalStartTime}}"}
                esphome uses the full key (e.g. state_topic) while Tasmota uses the accepted abbreviation (e.g. stat_t)

                esphome does not specify the acceptable content of the command topic. Tasmota does. This means mcsMQTT does not know how to setup value-status-pairs for the publish topic to control the esphome device. While esphome may have its own conventions the purpose of discovery is so the outside world can learn the conventions.

                esphome fully specifies each topic while Tasmota specifies them as a base ("~" placeholder) and a suffix

                There may be more, but before the mcsMQTT will not work with ESPHome until I generalize the full vs. abreviated keys. I may also need to generalize the full topic vs. base+suffix form of the topic disclosure.

                I will also need to find an esphome component for something like the Sonoff S31 that has energy reporting to see how it specifies the multi-level json content or if it even does multi-level json.

                Comment


                  #9
                  I have the plugin updated per my comments above. I tried to test a RGBWW component and was not able to get the yaml file defined properly for it. I tried may combinations but none with success. I started with the example in the component library and it did not work becasue only channel 1 defined

                  Code:
                   
                   # Example configuration entry light:   - platform: rgbw     name: "Livingroom Lights"     red: output_component1     green: output_component2     blue: output_component3     white: output_component4  # Example output entry output:   - platform: esp8266_pwm     id: output_component1     pin: D1     max_power: 80%
                  I also tried variants of below with one type of error or other reported. How does one define a a RGBWW light in esphome?


                  Code:
                  light:
                    - platform: rgbww
                      name: "Livingroom Lights"
                      red: output_component1
                      green: output_component2
                      blue: output_component3
                      cold_white: output_component4
                      warm_white: output_component5
                      cold_white_color_temperature: 6536 K
                      warm_white_color_temperature: 2000 K
                  
                  output:
                  - platform: esp8266_pwm
                  id: output_component1
                  pin: D4
                  - platform: esp8266_pwm
                  id: output_component2
                  pin: D5
                  - platform: esp8266_pwm
                  id: output_component3
                  pin: D6
                  - platform: esp8266_pwm
                  id: output_component4
                  pin: D1
                  - platform: esp8266_pwm
                  id: output_component5
                  pin: D2
                  I also received many debug topics in the MQTT output from esphome. I did not configure any debug and just used the lastest download for setting it up. Gives one the impression of something this is not very mature.

                  Code:
                  11:08:18 PM livingroom/debug=[0;35m[C][mqtt.sensor:024]: MQTT Sensor 'HLW8012 Voltage':[0m
                  11:08:18 PM livingroom/debug=[0;35m[C][mqtt.sensor:028]:   State Topic: 'livingroom/sensor/hlw8012_voltage/state'[0m
                  11:08:19 PM livingroom/debug=[0;35m[C][mqtt.sensor:024]: MQTT Sensor 'HLW8012 Current':[0m
                  11:08:19 PM livingroom/debug=[0;35m[C][mqtt.sensor:028]:   State Topic: 'livingroom/sensor/hlw8012_current/state'[0m
                  11:08:19 PM livingroom/debug=[0;35m[C][mqtt.sensor:024]: MQTT Sensor 'HLW8012 Power':[0m
                  11:08:19 PM livingroom/debug=[0;35m[C][mqtt.sensor:028]:   State Topic: 'livingroom/sensor/hlw8012_power/state'[0m

                  Comment


                    #10
                    Working here fine with my Home Assistant. Sees everything.

                    IE:

                    Weather:

                    Sub: homeassistant/sensor/weather_precipitation/attribution "Weather forecast from met.no, delivered by the Norwegian Meteorological Institute."

                    Squeezebox Players:

                    Sub: homeassistant/media_player/ics_jog_sqp_17/media_content_id "BBC World Service News (UK)"

                    Kodi Players, Alexa devices, Alarm panel, Sonoff devices, et al.
                    - Pete

                    Auto mator
                    Homeseer 3 Pro - 3.0.0.548 (Linux) - Ubuntu 18.04/W7e 64 bit Intel Haswell CPU 16Gb- Mono 6.12.X
                    Homeseer Zee2 (Lite) - 3.0.0.548 (Linux) - Ubuntu 18.04/W7e - CherryTrail x5-Z8350 BeeLink 4Gb BT3 Pro - Mono 6.12.X
                    HS4 Pro - V4.1.7.0 - Ubuntu 18.04/VB W7e 64 bit Intel Kaby Lake CPU - 32Gb - Mono 6.12.x
                    HS4 Lite -

                    X10, UPB, Zigbee, ZWave and Wifi MQTT automation. OmniPro 2, Russound zoned audio, Smartthings hub, Hubitat Hub, and Home Assistant

                    Comment


                      #11
                      Pete, Can you clarify if HS devices are created automatically for the HomeAssistant devices or it mcsMQTT only shows them on the Association tab?

                      Comment


                        #12
                        Originally posted by Pete View Post
                        Working here fine with my Home Assistant. Sees everything.

                        IE:

                        Weather:

                        Sub: homeassistant/sensor/weather_precipitation/attribution "Weather forecast from met.no, delivered by the Norwegian Meteorological Institute."

                        Squeezebox Players:

                        Sub: homeassistant/media_player/ics_jog_sqp_17/media_content_id "BBC World Service News (UK)"

                        Kodi Players, Alexa devices, Alarm panel, Sonoff devices, et al.
                        I have been playing with Home Assistant. Very nice!!!

                        Comment


                          #13
                          Here just updated the plugin and looked at the topics created. I did not touch or modify anything in the plugin.

                          At this moment looking at all of my devices in Homeseer and yes I see one Home Assistant device that was created. No more though.

                          This specific Amazon Dot is connected to the Zoned audio source which is mixed in with the Homeseer SAPI voices.

                          Click image for larger version  Name:	HS-HA.jpg Views:	0 Size:	10.5 KB ID:	1363722

                          Ahh...see that I associated this device last year. So no HA devices are being automatically created.
                          - Pete

                          Auto mator
                          Homeseer 3 Pro - 3.0.0.548 (Linux) - Ubuntu 18.04/W7e 64 bit Intel Haswell CPU 16Gb- Mono 6.12.X
                          Homeseer Zee2 (Lite) - 3.0.0.548 (Linux) - Ubuntu 18.04/W7e - CherryTrail x5-Z8350 BeeLink 4Gb BT3 Pro - Mono 6.12.X
                          HS4 Pro - V4.1.7.0 - Ubuntu 18.04/VB W7e 64 bit Intel Kaby Lake CPU - 32Gb - Mono 6.12.x
                          HS4 Lite -

                          X10, UPB, Zigbee, ZWave and Wifi MQTT automation. OmniPro 2, Russound zoned audio, Smartthings hub, Hubitat Hub, and Home Assistant

                          Comment


                            #14
                            I googled around to setup the yaml file for ESPHome to evaluate the HomeAssistant discovery that it implemented. In all cases ESPHome did not have payload template information per the HomeAssistant convention. It did make-up a "mode" key to disclose the climate control options rather than using the value template key.

                            I developed some rules in mcsMQTT version 5.1.3.0 at http://mcsSprinklers.com/mcsMQTT_5_1_3_0.zip to deal with this lack of information from ESPHome that provide what seems to me to be a reasonable device creation in HS. Other firmware (e.g. ESPurna) likely has their own flavor of HomeAssistant discovery and will deal with it when somebody uses this or other firmware.

                            Pete ... are you able to capture the data for the topic starting with homeassistant/ and ending with /config. This is the discovery disclosure. Since there was quite a bit of difference between Tasmota and ESPHome on the actual implementation I expect the same wild-west rules will apply for others as well.

                            For Tasmota the following was created for a Light. Similar look for other Tasmota device types. The plugin does all the conversions necessary for the two way communications with the Tasmota light.
                            Click image for larger version  Name:	Capture1.PNG Views:	0 Size:	123.8 KB ID:	1363770

                            For ESPHome I evaluated a number of configurations. The HS auto-device creation looks like below for what I tested.

                            Click image for larger version  Name:	Capture5.PNG Views:	0 Size:	111.5 KB ID:	1363771

                            I would expect the ESPHome plugin by kris83 to provide additional features to ESPHome-centric users. For those that use a mixture of firmwares that talk MQTT then the HomeAssistant discovery convention should provide a good bridge for mcsMQTT.

                            Comment


                              #15
                              are you able to capture the data for the topic starting with homeassistant/ and ending with /config

                              yes

                              Dev: |homeassistant|config:availability_topic
                              Sub: homeassistant/sensor/omnilink/thermostat1temp/config:availability_topic
                              Pub: the following Topic on Device command

                              If I click on associate then I get a device creation but nothing automatic right now. All I see are my Omni Panel devices (> 400).

                              I do not see any Espurna / Tasmota devices that are in HA.
                              - Pete

                              Auto mator
                              Homeseer 3 Pro - 3.0.0.548 (Linux) - Ubuntu 18.04/W7e 64 bit Intel Haswell CPU 16Gb- Mono 6.12.X
                              Homeseer Zee2 (Lite) - 3.0.0.548 (Linux) - Ubuntu 18.04/W7e - CherryTrail x5-Z8350 BeeLink 4Gb BT3 Pro - Mono 6.12.X
                              HS4 Pro - V4.1.7.0 - Ubuntu 18.04/VB W7e 64 bit Intel Kaby Lake CPU - 32Gb - Mono 6.12.x
                              HS4 Lite -

                              X10, UPB, Zigbee, ZWave and Wifi MQTT automation. OmniPro 2, Russound zoned audio, Smartthings hub, Hubitat Hub, and Home Assistant

                              Comment

                              Working...
                              X