Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support publishing custom value for relay processing #1085

Closed
iprak opened this issue Jul 28, 2018 · 5 comments
Closed

Support publishing custom value for relay processing #1085

iprak opened this issue Jul 28, 2018 · 5 comments
Labels
enhancement New feature or request mqtt relay
Milestone

Comments

@iprak
Copy link
Contributor

iprak commented Jul 28, 2018

It would be nice if on/off can be sent instead of 1/0. Incoming on/off messages are handled but only 1/0 get sent out. This will make interfacing and automating with Smartthings easier. I had prototyped introducing MQTT_TOPIC_RELAY_ON/MQTT_TOPIC_RELAY_OFF with default value 1/0 and custom value in hardware.h, and that seemed to work well.

@xbb1024
Copy link

xbb1024 commented Aug 3, 2018

hi, do you have a template smartthings device handler for espurna? I'm new to mqtt.

@iprak
Copy link
Contributor Author

iprak commented Aug 3, 2018

SmartThings events have to through a SmartApp/DeviceHandler into MQTT world through a bridge (https://hub.docker.com/r/stjohnjohnson/smartthings-mqtt-bridge/) to interact with Espurna device. My device is just of the type "Virtual Switch". The ST MQTT messages just end with on/off to indicate the state as well as the action and I was able to get this working by defining "smartthings/Device Name/switch" as the grouper, this felt quite odd but works and adjusting switch in ST gets reflected in Espurna device. But now the other way around since the outgoing messages have 1/0. So I locally end up creating 2 defines MQTT_TOPIC_RELAY_ON/MQTT_TOPIC_RELAY_OFF and used it in homeassistant.ino and relay.ino. I can request a pull if you want to look at it.

@xoseperez
Copy link
Owner

You can use "ON" and "OFF" (and "TOGGLE") for incoming MQTT messages. If you also want it to output strings instead of 0/1 you can use the latest dev branch and change the RELAY_MQTT_ON and RELAY_MQTT_OFF settings in general.h

@xoseperez xoseperez added enhancement New feature or request mqtt relay labels Aug 13, 2018
@xoseperez xoseperez added this to the 1.13.2 milestone Aug 13, 2018
@iprak
Copy link
Contributor Author

iprak commented Aug 13, 2018 via email

@xoseperez
Copy link
Owner

Good idea, but I'd prefer to use a different setting for that.

mcspr added a commit that referenced this issue Sep 3, 2019
- remove "platform" key, see #1440. this implicitly sets schema to "basic". pending some other clean-up regarding json and mqtt queueing, other schema can be added down the line 
- updated ws module queue elem to capture callbacks list, allows to pass more than one callback (for example, when they are generated on the fly as lambdas, see ha wsPost usage)
- modified method to send ha config to use global ws queue, fix #1762 problem with empty topics and ensure json allocation is consistent.
- use existing defines to set mqtt payload options. amend #1085, #1188, #1883 to use the set payload value. drop HOMEASSISTANT_PAYLOAD... defines. 
- update MQTT_STATUS_ONLINE/OFFLINE and RELAY_MQTT_ON/OFF with runtime configuration
- filter payload strings so that the resulting yaml value is not interpreted as bool (python True, False)
- helper method for settings to streamline string values manipulation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request mqtt relay
Projects
None yet
Development

No branches or pull requests

3 participants