Using PLEG to copy a sensor value to another



  • So I am having trouble trying to do something with PLEG. I have an outside temp sensor which is on my OneWire network. I also have my MySensors thermostat bridge that will accept a value for the outside temp that will get displayed on the actual wall thermostat display. I just present a separate device for the outside temp as a place to set the value. I am trying to find a way to copy the value from the OneWire sensor to the thermostat outside temp device. It would be nice if I could do it any time the value changes, but I would also accept doing it say every minute. When I look at the options for the temp sensor, all I have is "if the temp goes above", "if the temp goes below" or "if the battery goes below". Because of this I am assuming that I will have to do it once a minute, but maybe someone knows how to do it on change of the value. My main thing is that I can't figure out how to copy the value over.


  • Hero Member

    Just add LUA as a Logic Action triggered by a cyclic condition in PLEG
    Using Lua just get the value from the temp sensor variable and set the variable on the thermostat:

    local PipeTemp = luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1","CurrentTemperature", 42)
    luup.variable_set("urn:upnp-org:serviceId:TemperatureSensor1","CurrentTemperature",PipeTemp,44)
    
    


  • @korttoma Perfect. This is what I came up with in the end, and I have it triggering every minute. I needed the number rounded to the nearest whole number as the thermostat will not display a decimal value for the outside temp.

    local CurrentTemp= luup.variable_get("urn:upnp-org:serviceId:TemperatureSensor1","CurrentTemperature", 26)
    luup.variable_set("urn:upnp-org:serviceId:LcdText1", "LcdText", string.format("%.0f", CurrentTemp), 365)
    

    Thanks a million.


Log in to reply
 

Suggested Topics

  • 1
  • 5
  • 3
  • 6
  • 2

53
Online

11.4k
Users

11.1k
Topics

112.7k
Posts