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

Trying to do post in custom application - HC3


Question

Posted (edited)

Guys I am trying to do a "put" in a custom thermostat that I am building that will talk to my Honeywell Evohome. The problem is that I am geting a 404. I have tried this using a "curl" which executes successfully.

I believe that something is wrong with the body but I am unable to pinpoint the issue.

Any help will be appreciated.

 

curl -X PUT -H "sessionId: xxxxxxxxxxxxxxxxxxxxxxxxxxx" -H "Content-Type: application/json" -d '{"Value":"21.5","Status":"Temporary","NextTime":"2020-01-22T19:00"}' 'https://mytotalconnectcomfort.com/WebApi/api/devices/yyyyyyy/thermostat/changeableValues/heatSetpoint'

 

function QuickApp:TurnOnHeating(tempvalue)
    self:debug("Temperature Value", tempvalue)
    local sessionId = json.decode(tostring(fibaro.getGlobalVariable("HoneywellSessionId")))
    hour=os.date("%H")+1
    hour=tonumber(string.format("%.0f", hour))
    settime=os.date("%Y-%m-%d") .. "T" .. hour .. os.date(":%M")
    local address = "https://mytotalconnectcomfort.com/WepApi/api/devices/yyyyyyy/thermostat/changeableValues/heatSetpoint"
    self:debug("address: ", address)
    self:debug("Time that will be set:",settime)
    local requestBody = {
        action = "create",
        params = {
            value = tonumber(tempvalue),
            status = tostring("Temporary"),
            nextTime= tostring(settime)
        }
    }
    self.http:request(address, {
        options = {
            method = "PUT",
            data = json.encode(requestBody),
            headers = {
                ["sessionId"] = sessionId,
                ["Accept"] = "application/json",
                ["content-type"] = "application/json"
            }
        }, 
        success = function(response) 
            self:debug("response data:",response.data)
            self:debug("response status:", response.status) 
            self:debug("headers:", response.headers["Content-Type"]) 
            local data = json.decode(response.data)
        end,
        error = function(error)
            self:debug('error: ' .. json.encode(error))
        end
    }) 
end

 

Error

------

[23.01.2021] [13:39:23] [DEBUG] [QUICKAPP192]: onAction: {"deviceId":192,"args":["Heat"],"actionName":"setThermostatMode"}

[23.01.2021] [13:39:23] [DEBUG] [QUICKAPP192]: Mode that is set: Heat

[23.01.2021] [13:39:23] [DEBUG] [QUICKAPP192]: onAction: {"deviceId":192,"args":[20],"actionName":"setHeatingThermostatSetpoint"}

[23.01.2021] [13:39:23] [DEBUG] [QUICKAPP192]: Temperature Value 20

[23.01.2021] [13:39:23] [DEBUG] [QUICKAPP192]: address:

Please login or register to see this link.

[23.01.2021] [13:39:23] [DEBUG] [QUICKAPP192]: Time that will be set: 2021-01-23T14:39

[23.01.2021] [13:39:24] [DEBUG] [QUICKAPP192]: response data:

[23.01.2021] [13:39:24] [DEBUG] [QUICKAPP192]: response status: 404

[23.01.2021] [13:39:24] [DEBUG] [QUICKAPP192]: headers: text/html

[23.01.2021] [13:40:00] [DEBUG] [QUICKAPP192]: sessionId: yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy

Edited by 03397
Sensitive Info

2 answers to this question

Recommended Posts

  • 0
Posted

I don't know for sure what is wrong, but could it be the capitalisation of the keywords in the data? It differs between the curl example and your Lua example.

Also the 'create' wrapper differ but it may be another command compared to the curl example?

The same format as the curl example would look like

local requestBody = {
            Value = tonumber(tempvalue),
            Status = "Temporary",
            NextTime= settime
}
  • 0
  • Inquirer
  • Posted

    @

    Please login or register to see this link.

    I have tried you suggestion.

    I am getting the exact same error message 404.

    This thing is driving me crazy!!

     

    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...