Announcement

Collapse
No announcement yet.

Quick question about modifying values

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

    Quick question about modifying values

    Is it possible to do some math on a value before storing it in the device string?
    The reason i ask this is because i got a MQTT topic that sends me the uptime in minutes but it is getting a large number so i would like to store it as hours.
    A <value> mod 12 would give me hours.
    Is this possible and if so how do it do this?
    - Bram

    Send from my Commodore VIC-20

    Ashai_Rey____________________________________________________________ ________________
    HS3 Pro 3.0.0.534
    PIugins: ZMC audio | ZMC VR | ZMC IR | ZMC NDS | RFXcom | AZ scripts | Jon00 Scripts | BLBackup | FritzBox | Z-Wave | mcsMQTT | AK Ikea

    #2
    You can do it using either the regular expression or the expression textbox. Section 6.2 of mcsMQTT.pdf shows text manipulation using regular expressions. In particular example #4 does a manipulation of a date that could be a starting point for what you want. There are also Expression functions in Table 3 that manipulate strings so you can extract parts of the string and perhaps convert to number if that is what you wish.

    Comment


      #3
      Thanks,
      Section 6.3 presented the solution.
      The payload is a value in minutes.
      With $$PAYLOAD: / (60 * 24) i convert it to days. The HS device is setup to show a value with 2 decimals.
      So the decimal part isn't exactly in minutes but 14.40 parts of a hour but i don't mind that detail.
      Close enough for me.
      - Bram

      Send from my Commodore VIC-20

      Ashai_Rey____________________________________________________________ ________________
      HS3 Pro 3.0.0.534
      PIugins: ZMC audio | ZMC VR | ZMC IR | ZMC NDS | RFXcom | AZ scripts | Jon00 Scripts | BLBackup | FritzBox | Z-Wave | mcsMQTT | AK Ikea

      Comment

      Working...
      X