MQTT comunication between Indigo and Home assistant

Posted on
Fri Mar 13, 2020 11:29 am
haavarda offline
User avatar
Posts: 702
Joined: Aug 18, 2012
Location: Norway

MQTT comunication between Indigo and Home assistant

Thanks for a good plugin. With the covid situation here in Norway, I have plenty of time to play with my home automation systems.

I am trying to learn something about mqtt. And to do that I want to set up some communication between Indigo and Home assistant over mqtt. I am able to publish from indigo, and I am able to see the "package" on the developer tool in HA.
But for some reason I am not able to update any states in HA. Is there something with they way it is formatted in the mqtt plugin that could cause this?

Code: Select all
Message 7 received on indigo/variables/1085500151/update at 6:23 PM:
{ 'name': MQTT_Test, 'variableId':1085500151, 'value': ON }
QoS: 0 - Retain: true


Could it be possible to add support for the HA MQTT Discovery feature?
https://www.home-assistant.io/docs/mqtt/discovery/

Håvard

Håvard

Posted on
Sat Mar 14, 2020 5:00 am
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: MQTT comunication between Indigo and Home assistant

There’s two completely distinct issues here. First, you need to adjust the device publishing template to something that home assistant can deal with. If you can find some documentation on what that is, I can help adjust the template. The template is defined in one of the tabs of the connector device configuration dialog.

The second is the discovery protocol. I’ll take a look at that link when I get home this week and see what’s possible.

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

Posted on
Sat Mar 14, 2020 5:08 am
haavarda offline
User avatar
Posts: 702
Joined: Aug 18, 2012
Location: Norway

Re: MQTT comunication between Indigo and Home assistant

As a start I am trying to send some motion sensor data.
So I have tried to use this sensor in HA
https://www.home-assistant.io/integrations/binary_sensor.mqtt/
Not sure if this page gives you the information needed to adjust the template?

It also seams that their general information regarding mqtt is under this link:
https://www.home-assistant.io/integrations/mqtt/

Thanks for looking at this.

Håvard

Posted on
Sat Mar 14, 2020 7:06 am
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: MQTT comunication between Indigo and Home assistant

I think it does, but I’m going to need to be at my actual development system to get it working. I’ll be home mid-week and can look at it then.

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

Posted on
Sun Mar 15, 2020 4:02 am
haavarda offline
User avatar
Posts: 702
Joined: Aug 18, 2012
Location: Norway

Re: MQTT comunication between Indigo and Home assistant

Looking forward to it
Just let me know if I can help in any way.


Sent from my iPhone using Tapatalk

Håvard

Posted on
Thu Mar 19, 2020 3:57 pm
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: MQTT comunication between Indigo and Home assistant

Can you post the configuration.yaml entry for the binary sensor you're trying to set up?

If you're publishing a variable, and you only need to send the state of the sensor, the "Variable Publishing Template" should be something like:

Code: Select all
{{value}}

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

Posted on
Thu Mar 19, 2020 4:33 pm
haavarda offline
User avatar
Posts: 702
Joined: Aug 18, 2012
Location: Norway

Re: MQTT comunication between Indigo and Home assistant

Will try with the variable tomorrow.
When it comes to the binary sensor it am trying to get data from a motion sensor in indigo over to HA.

Not sure if I understand you correctly. But I have tried to populate the following:
I use motion instead of opening in the last part.

Code: Select all
   # Example configuration.yaml entry
binary_sensor:
  - platform: mqtt
    name: "Window Contact Sensor"
    state_topic: "home-assistant/window/contact"
    payload_on: "ON"
    payload_off: "OFF"
    availability_topic: "home-assistant/window/availability"
    payload_available: "online"
    payload_not_available: "offline"
    qos: 0
    device_class: opening
    value_template: '{{ value.x }}' 



Sent from my iPhone using Tapatalk

Håvard

Posted on
Thu Mar 19, 2020 4:40 pm
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: MQTT comunication between Indigo and Home assistant

You need to change the "state_topic" to match what Indigo sends, which is "indigo/variables/1085500151/update".

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

Posted on
Fri Mar 20, 2020 3:28 am
haavarda offline
User avatar
Posts: 702
Joined: Aug 18, 2012
Location: Norway

Re: MQTT comunication between Indigo and Home assistant

Thanks for looking at this, and I have some progress.

I have defined two different sensors. One that is based on a z-wave sensor, and one that is just a variable.
I have been playing back and forth with the configuration in the last week or so. But when I changed the variable template as you suggested, I was able to get that to work.
Any idea on how to get the sensor to work?

Code: Select all
# MQTT Setup
binary_sensor:
  - platform: mqtt
    name: "Switch MQTT test"
    state_topic: "indigo/variables/1085500151/update"
    payload_on: "on"
    payload_off: "off"
    qos: 0


  - platform: mqtt
    name: "Motion Sensor Office"
    state_topic: "indigo/devices/1358686939/update"
    payload_on: "True"
    payload_off: "False"
    qos: 0
    device_class: motion



Could the value template configuration in HA adjust for the publish template in your plugin?

value_template
(string)(Optional)
Defines a template that returns a string to be compared to payload_on/payload_off. Available variables: entity_id. Remove this option when ‘payload_on’ and ‘payload_off’ are sufficient to match your payloads (i.e no pre-processing of original message is required).

Håvard

Posted on
Fri Mar 20, 2020 3:37 am
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: MQTT comunication between Indigo and Home assistant

Honestly, the easiest way to do what you want is to not "Publish" the Z-wave sensor, but to use a trigger that fires whenever the motion sensor changes, Then use the MQTT "Publish Message" action to send an MQTT message with the specific topic and payload you want. Use the state substitution syntax to include just the motion sensor state in the payload.

If you're doing a LOT of devices, that might not be best because you would need a trigger and associated actions for each device.

If you have to use device publishing, then you need to rewrite the device publishing template to only send the value of a specific state.

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

Posted on
Fri Mar 20, 2020 3:52 am
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: MQTT comunication between Indigo and Home assistant

Ok, maybe using device publishing isn't that bad. As long as you only want to publish one kind of device. Try using this as the template:
Code: Select all
{{states.onOffState}}

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

Posted on
Fri Mar 20, 2020 4:09 am
haavarda offline
User avatar
Posts: 702
Joined: Aug 18, 2012
Location: Norway

Re: MQTT comunication between Indigo and Home assistant

hmmm
That last one is not working.
When I use a mqtt explorer it just publishes update.
Attachments
Skjermbilde 2020-03-20 kl. 11.21.13.png
Skjermbilde 2020-03-20 kl. 11.21.13.png (96.31 KiB) Viewed 2668 times

Håvard

Posted on
Fri Mar 20, 2020 5:44 am
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: MQTT comunication between Indigo and Home assistant

Hmm. The docs say that should work. I'll do some more research. But since it looks like you're ALSO doing value sensors, changing the template is not the best solution.

I would suggest trying the Trigger/Publish Message solution.

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

Posted on
Fri Mar 20, 2020 5:56 am
haavarda offline
User avatar
Posts: 702
Joined: Aug 18, 2012
Location: Norway

Re: MQTT comunication between Indigo and Home assistant

I am not a programmer, but I think that since the data that comes from your plugin contains several states (as default), it is needed to extract the needed data from the string (?).
And I think this is what is described on this page as template. https://www.home-assistant.io/docs/configuration/templating/#processing-incoming-data.
Then we would need a json that tells what part of the string that contains the info about motion true/false. From the example:

Code: Select all
'{{value_json.on}}'


Code: Select all
# Example configuration.yaml entry
binary_sensor:
  - platform: mqtt
    name: "Window Contact Sensor"
    state_topic: "home-assistant/window/contact"
    payload_on: "ON"
    payload_off: "OFF"
    availability_topic: "home-assistant/window/availability"
    payload_available: "online"
    payload_not_available: "offline"
    qos: 0
    device_class: opening
    value_template: '{{ value.x }}'         #use this line to define where the payload is?



Am I on to something here?

My main goal with this is to use HA as a way to use google home in my system...

Håvard

Posted on
Fri Mar 20, 2020 6:00 am
FlyingDiver offline
User avatar
Posts: 7222
Joined: Jun 07, 2014
Location: Southwest Florida, USA

Re: MQTT comunication between Indigo and Home assistant

Then I think you would want:

Code: Select all
'{{value_json.states.onOffState}}'


And don't forget to change the template back to the default.

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

Who is online

Users browsing this forum: No registered users and 5 guests