Replies: 22 comments 2 replies
-
Whoa, this sounds crazy :-D Is there anyone, who has knowledge about this topic/system? |
Beta Was this translation helpful? Give feedback.
-
Nothing crazy there. Just one additional retained mqtt post with config. If I will make this project work on my Orange Pi I can get my hands on this. |
Beta Was this translation helpful? Give feedback.
-
Very interesting! It'd be great to implement this. I haven't come across it before, but I did design the topics for this project to be in line with ones used with Home Assistant.
Looking forward to seeing what you come up with @yozik04! Shout if you need any help or want to discuss the best way to handle the configuration or something. |
Beta Was this translation helpful? Give feedback.
-
Good Idea. This way all the devices could be listed with a simple "mqtt-list-topics". |
Beta Was this translation helpful? Give feedback.
-
This will be a great additional feature, and bring this great bit of software in line with my ESP8266 devices, they auto-create in Hass.io Thanks to yozik04, as I have been trying to work out how to do this and failed! |
Beta Was this translation helpful? Give feedback.
-
Yep, this has been merged and released in mqtt:
discovery: yes
# The following is optional (homeassistant is the default)
discovery_prefix: homeassistant
...etc Please try it out and update this issue with feedback if you can. |
Beta Was this translation helpful? Give feedback.
-
That was the magic bit I was missing.
Just tried it and Hass.IO discovered the device, it named it MQTT GPIO, as I have several devices is there a way to set this to a more meaningful name, like 'Heating Controller' or Irrigation' etc.?
David
>> On 26/02/2020 at 15:33, in message ***@***.***>, Ellis Percival ***@***.***> wrote:
Yep, this has been merged and released in 0.5.0, but I haven't actually configured my own one yet to test it out (a bit backwards, I know). Once I've done that I'll update the readme, but it looks like you just set the following in your config:
mqtt:
discovery: yes
# The following is optional (homeassistant is the default)
discovery_prefix: homeassistant
...etc
Please try it out and update this issue with feedback if you can.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
--
This email was Anti Virus checked by Astaro Security Gateway. http://www.sophos.com
|
Beta Was this translation helpful? Give feedback.
-
Ah, good feedback. I've just pushed a new version mqtt:
discovery: yes
# The following is optional (homeassistant is the default)
discovery_prefix: homeassistant
# Optional too, but change to whatever you like
discovery_name: MQTT GPIO
...etc Please give that a spin. |
Beta Was this translation helpful? Give feedback.
-
That did the trick, makes this a superb bit of code to use with my Pi Zeros and Hass.
Many thanks.
David
|
Beta Was this translation helpful? Give feedback.
-
I have been doing some more testing and have found a strange situation on one of my devices.
This Pi has a GPIO input set as follows, as the input goes low when on I have inverted the call.
- name: hot_water
module: raspberrypi
pin: 26
on_payload: "OFF"
off_payload: "ON"
pullup: yes
pulldown: no
retain: no
This is sent correctly as part of the MQTT message when I check in MQTT Explorer, and shows OFF when the program is run and pin is high.
But Home Assistant shows the entity it creates as ON. everything is reversed, I have cleared and reset the system several times and it is always reversed.
I think the issue is the discovery message sends the payload settings (which I have reversed), so reversing them again,
{"name": "hot_water", "unique_id": "pi-mqtt-gpio-b4baea8f_raspberrypi_input_hot_water", "state_topic": "heating-mgr/input/hot_water", "availability_topic": "heating-mgr/status", "payload_available": "running", "payload_not_available": "dead", "payload_on": "OFF", "payload_off": "ON", "device": {"manufacturer": "MQTT GPIO", "identifiers": ["mqtt-gpio", "pi-mqtt-gpio-b4baea8f"], "name": "heating-mgr"}}
I rem'd out the two lines in the code, cleared the integration in Hass, and then restarted Hass.io and then the Pi, this is now reporting correctly.
David
|
Beta Was this translation helpful? Give feedback.
-
It actually should send |
Beta Was this translation helpful? Give feedback.
-
I agree it should be set, but if you read my earlier posting you will notice that I have reversed the sense of the settings on the PI as my GPIO pin goes low when 'ON'. This sends the correct msg via MQTT, a Low Pin sends 'ON' as it should do. But Hass reads the configuration sent and sees the reversed settings and flips it back again, a double-negative, so in the States panel (and Lovelace) a 'ON' MQTT message is reversed to show as 'OFF'. Try this out for yourself. David |
Beta Was this translation helpful? Give feedback.
-
I got your point. If I won’t send it then there will be an other problem. Maybe some new parameter for fliping? |
Beta Was this translation helpful? Give feedback.
-
I think it would work if you don't read the .yaml file but always set them as default values expected by Hass, the flipping is then done by the config file. |
Beta Was this translation helpful? Give feedback.
-
@flyte @dpritt has a valid point. It is very easy to change it for you. I do not think a pull request is required. |
Beta Was this translation helpful? Give feedback.
-
I wasn't sure if hardcoding the payloads would work if someone wanted to change the payloads away from the default values, so I've added an digital_inputs:
- name: hot_water
module: raspberrypi
pin: 26
on_payload: "ON"
off_payload: "OFF"
inverted: yes
pullup: yes
pulldown: no
retain: no @dpritt would you be able to test this out by pulling the |
Beta Was this translation helpful? Give feedback.
-
Ellis, The changes you made work a treat, the test switches I created are correctly created in HA, and the logic works. However do you need to now include the default settings for on_payload and off_payload in the configuration file, it could get confusing. These should be sent as defaults and you only need the' inverted:' line now in the configuration yaml. As well as the toggle switches I have also tested a button using the interrupt_payload: "trigger" option. A normal Binary_Sensor entity is created in HA, but it does not respond to the MQTT message as this expects ON or OFF'. For a button to work we need to use a 'MQTT Device Trigger' as outlined here https://www.home-assistant.io/integrations/device_trigger.mqtt/ This needs a 'type' setting up in the discovery module, there are a number of options available, but the default has to be 'button_short_press'. This 'type' could be added to the configuration yaml to allow the user to select one of the HA defined types. The 'hass_announce_digital_input' code would need to detect this and sending the relevant discovery message as shown in the HA documentation. Currently I cannot find a way to use buttons with hass and pi-mqtt-gpio. David |
Beta Was this translation helpful? Give feedback.
-
Indeed, I just included them in my comment for completeness.
Yeah, I suppose that could be added to the digital_inputs:
- name: button
module: raspberrypi
pin: 26
interrupt_payload: trigger
ha_type: button_short_press
pullup: yes
interrupt: falling
bouncetime: 200
retain: no I probably won't get round to this this week, as I'm a little busy, but PRs are of course very welcome. |
Beta Was this translation helpful? Give feedback.
-
hey, can we already use also, ha mqtt receive Maybe you can create special trigger with regular on/off_payload options w/o separate It’s must have because I cannot create two triggers: falling with OFF payload and raising with ON payload with the same name. |
Beta Was this translation helpful? Give feedback.
-
Fix this in home assistant. Under -platform: mqtt in configuration.yaml: |
Beta Was this translation helpful? Give feedback.
-
Unfortunately we don't get information from the interrupt to say what the value of the pin (or even which pin it is sometimes) is that's triggered the interrupt, so we can't publish different payloads when it's turned ON or OFF. To be honest, I wouldn't (and in fact don't, for my motion detectors) use interrupts for motion detection, since most PIR sensors hold the trigger on for at least a few seconds when motion is detected, and this is plenty of time for this software to poll the input and send an MQTT message. This way you don't have to worry about turning off the HA device after motion has been detected, because you'll receive the OFF message as normal. |
Beta Was this translation helpful? Give feedback.
-
I'm going back a bit to the beginning of this thread. I'm trying to make my digital_outputs show up in Home Assistant. But when I add discovery: yes to my config file, all I get is
|
Beta Was this translation helpful? Give feedback.
-
Would be great to have.
Beta Was this translation helpful? Give feedback.
All reactions