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

Add reason field for inputs and output state changes #138

Closed
TD22057 opened this issue Mar 30, 2019 · 6 comments
Closed

Add reason field for inputs and output state changes #138

TD22057 opened this issue Mar 30, 2019 · 6 comments

Comments

@TD22057
Copy link
Owner

TD22057 commented Mar 30, 2019

From HA forum:

@parkercat Interesting idea. I think it’s possible - but it will require changes to the library. Insteon devices have basically two ways for a device to change. 1) if a button is pressed and 2) when the device responds to a scene. So I can add a “reason” tag or something like similar that could be added to the json payload to track the difference between a button press or scene response. It should also be possible to have an optional input reason field in the MQTT payload which could also be passed through and show up in the output state message. That would add a 3rd reason category which is somewhat user set’able since whatever reason you pass in via the MQTT could show up in the state change.

I think that would allow your automations to respond differently depending on the context by setting the reason field when sending commands and checking it in automations to decide whether to respond or not.

@crxporter
Copy link

My openhab installation went to pot this week so I’m jumping ship.

I came here today to check progress and specifically find out if this setup could distinguish between a dimmer button press and a group update.

Take this as my plus one vote for this feature.

I will be moving my system over to Insteon-mqtt in the coming weeks as I have time, I’m excited to join!

@TD22057
Copy link
Owner Author

TD22057 commented Apr 7, 2019

If anyone wants to help test the reason field, I've added an initial cut for the Switch device and it appears to be working. I still need to add support for the other devices and add docs and tests. These updates are available on the 'reason' branch.

Changes include:

  • Added output reason field to the json templating for the state messages.
  • Added reason inputs to on(), off(), set(), and scene() commands on the device.
  • Default reasons are:
    • 'device' : when a button is pressed (or the device triggers the state change)
    • 'scene' : when the device is a responder to a scene trigger
    • 'command' : when the state changes from a direct on/off command
    • 'refresh' : when the state is reported from a refresh call
  • Added option reason input field to inbound MQTT on/off and scene commands. This can be set by adding "reason" = "text" to the json packet or using "-r text" on the command line. This reason overrides the default reasons above.

So you can add {{reason}} to the state template to see the reason in the output state MQTT message. Then you can pass input reasons in via MQTT for customization or just use the standard reasons shown above in automation processing.

@dlarrick
Copy link

dlarrick commented Apr 9, 2019

Hi Ted,
I am aka 'parkercat' in HA forum. Thanks for your guidance and support over there. This change is working well for me so far with my switch devices. I look forward to support on dimmer devices and (especially) on KeypadLinc buttons.

@TD22057
Copy link
Owner Author

TD22057 commented Apr 10, 2019

Pull the latest reason branch down - I pushed an update yesterday that adds reason to every device except thermostat. I haven't time to test anything but switch yet but the code was mostly a copy/paste so it will probably work ok (famous last words).

@TD22057
Copy link
Owner Author

TD22057 commented Apr 14, 2019

This is now finished and merged into the dev branch. It will be available with the next release (once I figure out how to build the hassio repo's and docker images).

@TD22057 TD22057 closed this as completed Apr 14, 2019
@TD22057
Copy link
Owner Author

TD22057 commented Apr 14, 2019

ps: reason support was added for these devices: Outlet, Switch, Dimmer, FanLinc, KeypadLinc. I didn't add this to IOLinc or Thermostat because of there added complexity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants