Announcement

Collapse
No announcement yet.

Feature Request: Run script after receiving MQTT message

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Feature Request: Run script after receiving MQTT message

    Michael,
    There are several cases where I would like to have the value and string of a device updated when an MQTT message is received.

    An example would be uptime. It is best if the value sent by the sensor is in seconds. This way an event can run based on a threshold. For instance, if the uptime is less than 10 seconds, send an alert. Or if it's over one week, reboot the device.

    On the other hand, a human-readable value is also nice, so at a glance, it's easy to understand. For instance, 2d 2h 2m is a whole lot easier to understand than 180,120.

    An easy way to make this work would be to run a script after an MQTT message is received. The device ID and payload would need to be able to be passed into the script as parameters. Not really too interested in running a script via an event. It's too easy for device associations to be lost, events don't survive HS software upgrades very well, a new event would have to be created for each device (no way to pass in the device ID for the device that triggered the event), no way to pass in the MQTT topic, etc.

    Other than my particular uptime example. I'm sure there are plenty of other instances where running a script after the value is received would be helpful.

    Is it possible to add a field to the association or manual tab where the path to a script can be added? The PI would need to pass in the Device ID as well as Payload to the script. Might even be handy to have the topic passed to the script as well.
    Last edited by mwolter; April 18th, 2018, 12:08 PM.
Working...
X