Home Assistant MQTT Discovery

Posted on
Thu Apr 23, 2020 5:17 pm
Hackencrash offline
User avatar
Posts: 205
Joined: Dec 16, 2015
Location: UK

Re: Home Assistant MQTT Discovery

Thanks - sorry about that!

I like the indigo.server.log trick - must use that more often. See attachment (too big to post as text on forum page really)

FYI I've just rebooted and done another MQTT cut and paste and it differs from the attachment:

23/04/2020, 23:33:27 indigo/light/1121785643/config q0 r0 i0 (518) #5 (taken just before post)
"name": "Dining Room Desk Light", "deviceId": "1121785643", "model": "Mulitlevel Switch", "address": "9", "states": { "brightnessLevel": "31", "onOffState": "True" } }, "capabilities": { "supportsAllLightsOnOff": "True", "supportsAllOff": "True", "supportsColor": "True", "supportsRGB": "True", "supportsRGBandWhiteSimultaneously": "True", "supportsStatusRequest": "True", "supportsTwoWhiteLevels": "True", "supportsTwoWhiteLevelsSimultaneously": "True", "supportsWhite": "True", "supportsWhiteTemperature": "True" } }
Attachments
light.txt
(7.5 KiB) Downloaded 14 times

Posted on
Thu Apr 23, 2020 6:09 pm
FlyingDiver offline
User avatar
Posts: 4417
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Home Assistant MQTT Discovery

Oops. My bad. I forgot that those attributes could be present with a False value. Will fix ASAP.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Thu Apr 23, 2020 6:29 pm
FlyingDiver offline
User avatar
Posts: 4417
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Home Assistant MQTT Discovery

Try 0.4.4

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Thu Apr 23, 2020 9:24 pm
Hackencrash offline
User avatar
Posts: 205
Joined: Dec 16, 2015
Location: UK

Re: Home Assistant MQTT Discovery

Yes this is great and appears to report correctly - Perfect! :D :

Code: Select all
{
    "address": "9",
    "capabilities": {
        "supportsAllLightsOnOff": "False",
        "supportsAllOff": "False",
        "supportsColor": "False",
        "supportsRGB": "False",
        "supportsRGBandWhiteSimultaneously": "False",
        "supportsStatusRequest": "True",
        "supportsTwoWhiteLevels": "False",
        "supportsTwoWhiteLevelsSimultaneously": "False",
        "supportsWhite": "False",
        "supportsWhiteTemperature": "False"
    },
    "deviceId": "1121785643",
    "model": "Mulitlevel Switch",
    "name": "Dining Room Desk Light",
    "states": {
        "brightnessLevel": "36",
        "onOffState": "True"
    }
}
Did you intend to include the False values for the supportsXXX keys?

One minor thing also is that the default template you posted here earlier has a couple of squiggly brackets {} in the wrong place (missing one at start and one too many at end of states) as I was getting JSON validation errors. It should be that below I believe:

{ "name": "{{name}}",
"deviceId": "{{deviceId}}",
"model": "{{model}}",
"address": "{{address}}",
"states": { {{#states}} "{{name}}": "{{value}}", {{/states}} },
"capabilities": { {{#capabilities}} "{{name}}": "{{value}}", {{/capabilities}} } }

Posted on
Fri Apr 24, 2020 9:24 am
FlyingDiver offline
User avatar
Posts: 4417
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Home Assistant MQTT Discovery

Yes, the False values are intentional. Just for completeness. On the other hand, maybe it would be better to make the capabilities entry a list instead of a dict, and just include the key in the list for the values that are true. Which would get rid of the string values which really ought to be booleans. In that case, the payload would look like:

Code: Select all
{
    "name": "Dining Room Desk Light",
    "address": "9",
    "deviceId": "1121785643",
    "deviceTypeId": "zwDimmerType",
    "model": "Mulitlevel Switch",
    "subModel": "",
    "protocol": "ZWave",
    "states": {
        "brightnessLevel": "36",
        "onOffState": "True"
    }
    "capabilities": ["supportsStatusRequest"]
}

Note that there's some new fields in there that I haven't added to the template yet, but are already present in the data available.

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Fri Apr 24, 2020 11:52 am
FlyingDiver offline
User avatar
Posts: 4417
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: Home Assistant MQTT Discovery

I just posted 0.4.5. The output payload now looks like:

Code: Select all
{
    "name": "Example Dimmer",
    "address": "123456",
    "deviceId": "587622500",
    "deviceTypeId": "myDimmerType",
    "model": "Example Dimmer Module",
    "subModel": "",
    "protocol": "Plugin",
    "states": {
        "backlightBrightness": "0",
        "brightnessLevel": "51",
        "onOffState": "True"
    },
    "capabilities": [ "supportsStatusRequest" ]
 }


The new default template is:

Code: Select all
{
"name": "{{name}}",
"address": "{{address}}",
"deviceId": "{{deviceId}}",
 "deviceTypeId": "{{deviceTypeId}}",
"model": "{{model}}",
"subModel": "{{subModel}}", 
"protocol": "{{protocol}}",
"states": { {{#states}} "{{name}}": "{{value}}", {{/states}} },
"capabilities": [ {{#capabilities}} "{{name}}", {{/capabilities}} ]
}

joe (aka FlyingDiver)
my plugins: http://forums.indigodomo.com/viewforum.php?f=177

Posted on
Fri Apr 24, 2020 2:18 pm
Hackencrash offline
User avatar
Posts: 205
Joined: Dec 16, 2015
Location: UK

Re: Home Assistant MQTT Discovery

Yeah I’ll work with whatever you come up with in order for me to create a mapping between the Indigo and Google device types.

So far I’m using your MQTT plugin with the default template unmodified, although it looks like I’ll now have to update it to work with MQTT plugin v0.4.5. 8)

This then obviously sends lots of messages with every device update from Indigo to the MQTT server (in my case Mosquitto) but in the wrong format for Home Assistant to digest.

I have therefore modified the Home Assistant automations.yaml file so that it subscribes to this default Indigo MQTT messages topic. Each message received in Home Assistant from this topic fires an event which then republishes each message reformatted such that Home Assistant can digest it correctly.

It potentially resends 2 messages per message received from Indigo effectively back to itself in Home Assistant. The first of these 2 messages automatically creates the device in Home Assistant if it does not already exist (device with the same entity_id). This new Home Assistant device is effectively a clone of the device in Indigo. The second message to be resent formats the original message data correcxtly to set the status of this cloned device In Home Assistant so that it matches its master Indigo device.

Very simple really. Just one automations.yaml file to copy and that’s it - no other setting changes! The only thing I can’t do unfortunately is automatically place these cloned Home Assistant devices in the correct Rooms since room (folder) data is not stored as part of the device in Indigo.

Who is online

Users browsing this forum: No registered users and 0 guests