No announcement yet.

Cant seem to use part of a payload that is a device in an event.

  • Filter
  • Time
  • Show
Clear All
new posts

  • Cant seem to use part of a payload that is a device in an event.

    I am using a PIR/Temp/Humidity/light sensor that delivers a JSON formatted payload that looks like this:

    "state" : "OFF",
    "humidity" : "78.30",
    "motion" : "motion detected",
    "ldr" : "96",
    "temperature" : "20.30"

    I have created new devices for all and have subscribed successfully to the topic and am getting status updates on all the seperate devices in HS and can see the updates in both the mcsMQTT UI and in the HS UI - however, it would appear that I cannot trigger an event for the "motion" field.

    To simplify things in the sensor, I have changed the "motion detected" state to 1 and standby to 0 in the payload and I still cant get the event to fire off.

    I have successfully made an event that triggers successfully on the "ldr" field using a range, the same with the "temperature" field, just to prove that the data is being delivered properly.

    What might I be doing wrong that I cant seem to trigger an event from this device?

  • #2
    Event triggers in HS are based upon the DeviceValue property. When mcsMQTT initially created the motion device it say a payload of "motion detected" which looked to it as a text string so it assumed that this device should be setup to update DeviceStatus and not DeviceValue. If you later changed the payload it did not change the setup of the MQTT to HS device.

    What you want to do is use a device type that stores data in DeviceValue by doing an itemized mapping of text strings into numbers. These are Button and List. This is selected on the Edit tab of mcsMQTT. One you change the association type to Button (or List) then you can edit the ValueStatusPair (VSP) relationships on the same page. It is likely that you will find all the text strings that have been received in the payload so nothing else needed unless you may want to remove some that you will never use again. You remove them by entering the name only in the VSP text box. Look at the tool tip of manual for other guidance.

    In your ldr case the payload was a number so mcsMQTT created a Number type association with HS. Numbers are stored in DeviceValue and can take on a range attribute. In this case the VSP is not used.