Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0

Lua Code for Thermostat Mode


Question

Posted

i tried to execute belowcode but it shows Temperature below cut-off for 1 minute but thermostat mode is not Cool. No action taken but in actual thermostat is in cool mode

i think  local mode = hub.getValue(sID, "ThermostatMode") is wrong.
can you help to find correct code ?pls

local function handleCutOff()
    local mode = hub.getValue(sID, "ThermostatMode")
    if mode == "Cool" then
        print("Temperature below cut-off for 1 minute and thermostat mode is Cool. Turning off All Compressors.")
        local success, err = pcall(function()
            hub.call(sID, 'setThermostatMode', "Off")
        end)
        if not success then
            print("Error turning off All Compressors: " .. (err or "unknown error"))
        end
    else
        print("Temperature below cut-off for 1 minute but thermostat mode is not Cool. No action taken.")
    end
end

 

Recommended Posts

  • 0
Posted
On 12/31/2024 at 9:26 AM, Nadeem said:

i tried to execute belowcode but it shows Temperature below cut-off for 1 minute but thermostat mode is not Cool. No action taken but in actual thermostat is in cool mode

i think  local mode = hub.getValue(sID, "ThermostatMode") is wrong.
can you help to find correct code ?pls

local function handleCutOff()
   

    if mode == "Cool" then
        print("Temperature below cut-off for 1 minute and thermostat mode is Cool. Turning off All Compressors.")
        local success, err = pcall(function()
            hub.call(sID, 'setThermostatMode', "Off")
        end)
        if not success then
            print("Error turning off All Compressors: " .. (err or "unknown error"))
        end
    else
        print("Temperature below cut-off for 1 minute but thermostat mode is not Cool. No action taken.")
    end
end

 

 

 

 

the thermostatmode should be lowercase :) 

    local mode = hub.getValue(42, "ThermostatMode")
    print("mode1:",mode)
    local mode = hub.getValue(42, "thermostatMode")
    print("mode2:",mode)

 

console:

image.png.b94c67f18c3b4b6dcd45422c47913a4e.png

  • 0
  • Inquirer
  • Posted

    Thank you @brors94 

    is it possible to get direct set point value from lua code ? please can you write for me..
     

    like this fibaro:getValue(ID, "setpointtemperaturevalue")

    • 0
    Posted
    10 minutes ago, Nadeem said:

    Thank you @brors94 

    is it possible to get direct set point value from lua code ? please can you write for me..
     

    like this fibaro:getValue(ID, "setpointtemperaturevalue")

     

     

    Like this :) 
     

        local currentsetpoint = hub.getValue(42, "coolingThermostatSetpoint")
        print("currentsetpoint:",currentsetpoint)

     

     

    • 0
  • Inquirer
  • Posted

    Thank you brother ... you are 
    Also if you can advise me to know cooling/heating valve status from scenes
    sometimes relays are getting stuck for cooling valves or fan speed 1,2,3 

    so is there any way we can know realtime status of cooling valve on/off and fan speed 1,2,3 on/off 
    when i set temp 24 and room temp is 25 then cooling/heating valve will be on and fan speed auto or 1/2/3 

    • Like 1
    • 0
  • Inquirer
  • Posted

    and Also how we can know all available codes for any device like thermostatmode,setpointtemperaturevalue....etc so that it wil be easy to chose from listed codes

    • 0
    Posted
    3 hours ago, Nadeem said:

    and Also how we can know all available codes for any device like thermostatmode,setpointtemperaturevalue....etc so that it wil be easy to chose from listed codes


    Hello, you have to investigate values from the local API(Swagger) of HC3 device:

    Please login or register to see this image.

    /monthly_2025_01/image.png.50a90b98373f711f9663e2bd96c10b23.png" />

     

    on the right top corner select "devices" from the box:
    image.png.49e50469687abbe06e29661823dfe5fd.png

     

    then select command "GET devices/deviceID":
    image.png.3e8cafb8e466c5fef8aecfe266375b45.png

     

    push button "Try it out":

    Please login or register to see this attachment.

     

    write ID of the device and push "execute" button:
    image.png.bdd75ab6ab9c22fa5dcb297ede6cd44c.png

     

    and there it is:

    Please login or register to see this attachment.

    • 0
  • Inquirer
  • Posted

    @Jiri Dobsovic Thank you 
    i tried to do same.. didnt found related to my product requirement as per below, let me know if you can help to find out...

    Quote

     

    Also if you can advise me to know cooling/heating valve status from scenes
    sometimes relays are getting stuck for cooling valves or fan speed 1,2,3 

    so is there any way we can know realtime status of cooling valve on/off and fan speed 1,2,3 on/off 
    when i set temp 24 and room temp is 25 then cooling/heating valve will be on and fan speed auto or 1/2/3 

     

     

    • 0
    Posted

    Yea, the swagger is the "documentation" we got and the manuals on the forum/fibaro site. 

     

    But jgab on the forum have done alot of works and I have learnt alot from his toturial over the years :D 

    But you can also add quickapps and see the basic code for them if you go to add device-> other devices -> quick app -> then choose the type you want to try and give it a name -> edit the QA and see the basics. 

    Here is jgabs toturials on QA: 

     

     

    image.png.b1f2449cd6e1757a68297a7ff6d25995.png

    Please login or register to see this attachment.

     

     

     

     

    • 0
    Posted
    8 hours ago, Nadeem said:

    Thank you brother ... you are 
    Also if you can advise me to know cooling/heating valve status from scenes
    sometimes relays are getting stuck for cooling valves or fan speed 1,2,3 

    so is there any way we can know realtime status of cooling valve on/off and fan speed 1,2,3 on/off 
    when i set temp 24 and room temp is 25 then cooling/heating valve will be on and fan speed auto or 1/2/3 

     

    The valve status is a binary switch I guess?
    I only have electrical underfloor heating myself so dont have any experience with fans heating 

     

     

    but if you want to get a binary switch status you just does: 

     

    ID = 42 ---ID of switch/valve binary switch
    local test_boolean_value = hub.getValue(ID, "value")  ---return true or false :)
    print("test: ",test_boolean_value)

     

     

     

    • 0
  • Inquirer
  • Posted

    I GOT THIS WHEN I ENTER YOUR CODE WITH MY ID

    ITS THERMOTATIC SWITCH NOT BINARY SWITCH WHICH HAS COOLING VALVE,FAN SPEED1,2,3 

    AND I AM ATTACHING HERE THEIR PARAMETERS FOR YOUR BETTER UNDERSTANDING

    [DEBUG] [SCENE169]: test:

    IT JUST SHOWS BLANK,NOTHING SHOWS

    Please login or register to see this attachment.

    Please login or register to see this attachment.

    • 0
    Posted
    3 hours ago, Nadeem said:

    I GOT THIS WHEN I ENTER YOUR CODE WITH MY ID

    ITS THERMOTATIC SWITCH NOT BINARY SWITCH WHICH HAS COOLING VALVE,FAN SPEED1,2,3 

    AND I AM ATTACHING HERE THEIR PARAMETERS FOR YOUR BETTER UNDERSTANDING

    [DEBUG] [SCENE169]: test:

    IT JUST SHOWS BLANK,NOTHING SHOWS

    Please login or register to see this attachment.

    Please login or register to see this attachment.

     

     

     

    try this and se what actions it support and post here:
     

    test = api.get("/devices/42").actions or {}
    print("test:",json.encode(test))

     

     

     

    • 0
  • Inquirer
  • Posted

    Hello
    Below are results

    [05.01.2025] [12:44:33] [DEBUG] [SCENE173]: test: {"setThermostatMode":1,"setClimatePanelOverrideSchedule":1,"removeClimatePanelOverrideSchedule":0,"startUpdate":1,"setIndicatorValue":1,"updateFirmware":1,"setCoolingThermostatModeAndSetpoint":1,"abortUpdate":1,"setHeatingThermostatModeAndSetpoint":1,"setCoolingThermostatSetpoint":1,"setThermostatFanMode":1,"retryUpdate":1,"setHeatingThermostatSetpoint":1,"reconfigure":0}
     
    • 0
    Posted
    1 hour ago, Nadeem said:

    Hello
    Below are results

    [05.01.2025] [12:44:33] [DEBUG] [SCENE173]: test: {"setThermostatMode":1,"setClimatePanelOverrideSchedule":1,"removeClimatePanelOverrideSchedule":0,"startUpdate":1,"setIndicatorValue":1,"updateFirmware":1,"setCoolingThermostatModeAndSetpoint":1,"abortUpdate":1,"setHeatingThermostatModeAndSetpoint":1,"setCoolingThermostatSetpoint":1,"setThermostatFanMode":1,"retryUpdate":1,"setHeatingThermostatSetpoint":1,"reconfigure":0}
     

     

    hmm 


    I see you have the setThermostatFanMode Do you have a picture of the device and how you manualy adjust the fan speed? 
    I dont have any thermostat with fanmode so got no experience with it.          
    maybe this gives you some value of fan speed?
     

    test = hub.getValue(41, "ThermostatFanMode")
    print("test:",json.encode(test))

     

    But to get the state of the relay in the termostat i dont know how. 

    With my electrical thermostat I got energy measurement that tells me if the relay is on/off 

     

     

    • 0
  • Inquirer
  • Posted

    its giving [17:13:36] [DEBUG] [SCENE175]: test: null
     

     

    you can video here for fan speed and left top is cooling valve control as per temperature setting.

    • 0
    Posted

    Ah :D Was thinking of the Device view in fibaro app/ webview :D 😅

    • 0
  • Inquirer
  • Posted

    haha...no issues
    pls look below

    Please login or register to see this image.

    /monthly_2025_01/image.png.984269a6504172a0ba913cebed754616.png" />

    • 0
    Posted

    I will come back to you :D 

    Just have to figure out how to add that interface :)

    • 0
    Posted
    On 1/6/2025 at 7:11 AM, Nadeem said:

    haha...no issues
    pls look below

    Please login or register to see this link.

     

     

    I think it was a typo xD
    the T in thermostat should be lowercase 😮 😅
    This should give you the fan state :D
    But you wanted relay state to? didnt you? 

     

    function QuickApp:t1()
    test = hub.getValue(self.id, "thermostatMode")
    print("test:",test)
    end

     

     

    • 0
  • Inquirer
  • Posted

    Hello
    i am looking for cooling valve status not for thermostat mode as per this video.
     

    On 1/5/2025 at 5:14 PM, Nadeem said:

    its giving [17:13:36] [DEBUG] [SCENE175]: test: null
     

     

    you can video here for fan speed and left top is cooling valve control as per temperature setting.

     

    • 0
    Posted (edited)

    I see know i was to fast on last post too 😅 Sorry for that.

    This one should give fanmode in return if you need it:

    test = hub.getValue(self.id, "thermostatFanMode")
    print("test2:",test)


    and for the valve we have to look for other interfaces that the thermostat have to.
    ( I dont know if we can read that value, but we have to look into it, But I am afraid that value cant be read out) 
    Would have gone alot faster if I have had it myself to 😆

    What does this print? (change 149 to the id of the thermostat) 

    test = api.get("/devices/149").interfaces or {}
    print("test:",json.encode(test))


     

    Edited by Brors94

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Answer this question...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...