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

Fibaro HC3 and Home Assistant REST API


Question

Posted

Good afternoon. Please help! -)I need to flip the switch in Home Assistant from PC3. How to do it ?! All that has succeeded at the moment is to reach out to the Home Assistant. And he will receive some kind of answer, but since I do not understand this, he gives me little - ( and sorry for my english. this is Google translate -)

____________________________________________

net.HTTPClient (): request ("http://xxx.xxx.xxx.xxx:8123/api/states/light.detsk_695", {
      options = {
        headers = {
            ['Content-Type'] = 'application / json',
            [ 'Authorization'] = 'Bearer xxxxxxxxxxxxxxxxxxxxxxxxxxx,
        },
        method = "GET"
        },
      success = function (response)
        self: debug ("Result:", json.encode (response))
      end,
      error = function (message)
        self: error (message)
      end
    })
end


I get an answer and see a lot of things, but how to work with it - ((

answer

 

[QUICKAPP802]: {"entity_id": "light.detsk_svet_chern", "state": "off", "attributes": {"supported_color_modes": ["brightness"], "friendly_name": "\u0414\u0435\u0442\u0441\u043a. \u0421\u0432\u0435\u0442 \u0427\u0435\u0440\u043d", "supported_features": 1}, "last_changed": "2021-10-22T04:54:09.421515+00:00", "last_updated": "2021-10-22T04:54:09.421515+00:00", "context": {"id": "xxxxxxxxxxxxxxxxxxxxxxxxxxx", "parent_id": null, "user_id": null}}

_________________________________________

My attempt to push

 

net.HTTPClient():request("http://xxx.xxx.xxx.xxx:8123/api/services/switch/turn_on",{
      options={
        data =  " {\"entity_id\" : \"light.children\"}" , "{\"state\": \"on\" }" ,
       state = "on",
        headers = {
            ['Content-Type'] = 'application/json',
            ['Authorization'] = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
        },
        method = "POST"
        },
      success=function(response)
        self:debug("Result:",json.encode(response))
      end,
      error=function(message)
        self:error(message)
      end
    })
end

 

answer

 

UIEvent: {"values":[],"elementName":"button3","deviceId":802,"eventType":"onReleased"}
 [DEBUG] [QUICKAPP802]: HA TEST GO
 [DEBUG] [QUICKAPP802]: Result: {"status":200,"data":"[]","headers":{"Connection":"close","Server":"Python\/3.9 aiohttp\/3.7.4.post0","Content-Type":"application\/json","Content-Length":"2","Date":"Fri, 22 Oct 2021 07:25:48 GMT"}}

 

HELP PLZ -)

0 answers to this question

Recommended Posts

There have been no answers to this question yet

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