Skip to content

Instantly share code, notes, and snippets.

@acidjunk
Created February 10, 2018 09:11
Show Gist options
  • Select an option

  • Save acidjunk/3e6dbc50e0faf11146b2b43287e63d75 to your computer and use it in GitHub Desktop.

Select an option

Save acidjunk/3e6dbc50e0faf11146b2b43287e63d75 to your computer and use it in GitHub Desktop.

Revisions

  1. acidjunk created this gist Feb 10, 2018.
    34 changes: 34 additions & 0 deletions cv.lua
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,34 @@
    --------------------------------
    ------ Start of edit section ------
    --------------------------------
    local desired_temp = 14.0 --Desired temp
    local hysteresis = 0.03 --Marge
    local sensor = 'Temperatuur' --Name of sensor
    local thermostat = 'cv_master' --Master switch (virtuel)
    local radiateur = 'cv_switch' --Device to switch on/off
    --------------------------------
    -- End of edit section --
    --------------------------------

    commandArray = {}
    if (devicechanged[sensor]) then
    print('Temperatuur updated from sensor.')
    local temperature = devicechanged[string.format('%s_Temperature', sensor)]
    print(temperature)
    if (otherdevices[thermostat]=='On') then
    print('Master switch is "On"')
    if (temperature < (desired_temp - hysteresis) ) then
    print('Switched CV On')
    commandArray[radiateur]='On'

    elseif (temperature > (desired_temp + hysteresis)) then
    print('Switched CV Off')
    commandArray[radiateur]='Off'
    else
    print ('No change needed')
    end
    else
    print('Master switch is "Off"; ignoring current and desired temperature')
    end
    end
    return commandArray