Új hozzászólás Aktív témák

  • yogee

    tag

    válasz Magga #4027 üzenetére

    Hi!
    Szerintem így kell kinéznie a scriptnek:

    local heating_probe = 'Nappali'
    local thermostat_setpoint = 'Thermo'
    local heating_unit = 'futes'

    -- Use when a combined sensor (e.g. temperature and humidity) is used
    -- Replace in "otherdevices[heating_probe]" to "otherdevices[heating_probe]" by "temp_only" (in the 2nd "if" and in the "elseif".
    -- Remove the -- in the next two lines:

    local naartekst = (tostring (otherdevices[heating_probe]))
    local temp_only = (string.sub(naartekst,1,4)) -- the digits (1,4) do point out what characters of the string are needed.


    local hysteresis = 0.1

    commandArray = {}


    -- loop through all the devices
    for deviceName,deviceValue in pairs(otherdevices) do
    if (deviceName== thermostat_setpoint ) then

    if tonumber(deviceValue) < tonumber(temp_only-hysteresis) then

    if (otherdevices[heating_unit] == "On") then
    -- commandArray['SendNotification']='Heating is off'
    commandArray[heating_unit]='Off'
    print("Heating is Off")
    end

    elseif tonumber(deviceValue) > tonumber(temp_only+hysteresis) then
    if (otherdevices[heating_unit] == "Off") then
    commandArray[heating_unit]='On'
    -- commandArray['SendNotification']='Heating is on'
    print("Heating is On")
    end
    end
    end
    end

    -- loop through all the variables
    for variableName,variableValue in pairs(uservariables) do

    end

    return commandArray

Új hozzászólás Aktív témák