RyanE Posted March 25, 2022 Share Posted March 25, 2022 1 hour ago, gimbers said: off/r/n The guys looking after the server say their server received: 6f 66 66 2f 72 2f 6e which is a literal translation. But what they actually need is: 6f 66 66 0d Carriage Return and Newline are *backslashes*, not *forward slashes*. \r\n RyanE Quote Link to comment Share on other sites More sharing options...
eon Posted November 28, 2022 Share Posted November 28, 2022 Hello i'm trying to send a post command to Home Assistant to control a light but having trouble to translate the format of the message, can somebody help me? The message i'm trying to send is: curl --location --request POST 'https://192.168.0.39:8123/api/services/light/turn_off' \ --header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiI5NjMxM2UzNTA1ZTc0ZWFlYmViZjEwMTg0MjE5NzlhNSIsImlhdCI6MTY2NTQyMDQ1MywiZXhwIjoxOTgwNzgwNDUzfQ.V8MO9vFarLCYsXBcq0ol6ZSiZiLb6JGrPp1wqMTg0Mj' \ --header 'Content-Type: application/json' \ --header 'Content-Type: text/plain' \ --data-raw '{"entity_id": "light.kid"}' I tried to put https://192.168.0.39:8123/api/services/light/turn_off in Web Address field and Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiI5NjMxM2UzNTA1ZTc0ZWFlYmViZjEwMTg0MjE5NzlhNSIsImlhdCI6MTY2NTQyMDQ1MywiZXhwIjoxOTgwNzgwNDUzfQ.V8MO9vFarLCYsXBcq0ol6ZSiZiLb6JGrPp1wqMTg0Mj; Content-Type: application/json&Content-Type: text/plain; {"entity_id": "light.kid"} In Post Data field but it is not working, i get a message in Home Assistant that there was ilegal login from ip address of the controller. When i use this request from postman its working ok. Any suggestions? Quote Link to comment Share on other sites More sharing options...
lippavisual Posted November 28, 2022 Share Posted November 28, 2022 You need to add your username and password to the url. Like this: https://username:password@192.168.0.39:8123/api/services/light/turn_off' Quote Link to comment Share on other sites More sharing options...
Alejandro Colombo Posted February 20, 2023 Share Posted February 20, 2023 On 11/28/2022 at 6:53 AM, eon said: Hello i'm trying to send a post command to Home Assistant to control a light but having trouble to translate the format of the message, can somebody help me? The message i'm trying to send is: curl --location --request POST 'https://192.168.0.39:8123/api/services/light/turn_off' \ --header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiI5NjMxM2UzNTA1ZTc0ZWFlYmViZjEwMTg0MjE5NzlhNSIsImlhdCI6MTY2NTQyMDQ1MywiZXhwIjoxOTgwNzgwNDUzfQ.V8MO9vFarLCYsXBcq0ol6ZSiZiLb6JGrPp1wqMTg0Mj' \ --header 'Content-Type: application/json' \ --header 'Content-Type: text/plain' \ --data-raw '{"entity_id": "light.kid"}' I tried to put https://192.168.0.39:8123/api/services/light/turn_off in Web Address field and Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiI5NjMxM2UzNTA1ZTc0ZWFlYmViZjEwMTg0MjE5NzlhNSIsImlhdCI6MTY2NTQyMDQ1MywiZXhwIjoxOTgwNzgwNDUzfQ.V8MO9vFarLCYsXBcq0ol6ZSiZiLb6JGrPp1wqMTg0Mj; Content-Type: application/json&Content-Type: text/plain; {"entity_id": "light.kid"} In Post Data field but it is not working, i get a message in Home Assistant that there was ilegal login from ip address of the controller. When i use this request from postman its working ok. Any suggestions? Hi you can make your curl request curl --location --request POST 'https://192.168.0.39:8123/api/services/light/turn_off' \ --header 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiI5NjMxM2UzNTA1ZTc0ZWFlYmViZjEwMTg0MjE5NzlhNSIsImlhdCI6MTY2NTQyMDQ1MywiZXhwIjoxOTgwNzgwNDUzfQ.V8MO9vFarLCYsXBcq0ol6ZSiZiLb6JGrPp1wqMTg0Mj' \ --header 'Content-Type: application/json' \ --header 'Content-Type: text/plain' \ --data-raw '{"entity_id": "light.kid"}' so in your LUA driver function Light_OFF() local data = "{\"entity_id\": \"light.kid\"} " local headers = {} headers["Content-Type"] = "application/json" headers["Content-Type"] = "text/plain" headers["Authorization"] = "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiI5NjMxM2UzNTA1ZTc0ZWFlYmViZjEwMTg0MjE5NzlhNSIsImlhdCI6MTY2NTQyMDQ1MywiZXhwIjoxOTgwNzgwNDUzfQ.V8MO9vFarLCYsXBcq0ol6ZSiZiLb6JGrPp1wqMTg0Mj" local ticketId = C4:urlPost("https://192.168.0.39:8123/api/services/light/turn_off", data, headers, true, Process_LightOFF) end function Process_LightOFF(ticketId, strData, responseCode, tHeaders, strError) print("Light response") print("strData: " .. strData) print(responseCode) end Quote Link to comment Share on other sites More sharing options...
zaphod Posted October 19, 2023 Share Posted October 19, 2023 If you guys are going to update this driver is it possible to have a way to send data for variables to Control4? Currently I can send commands like http://192.168.1.12:52690/OfficeLightOn, but is there any way you could have it accept URLs like http://192.168.1.12:52690/SetVariables?Temp1=26 where Temp1 is a variable that is existing in Control4? Or something similar? Or is there another way to do this currently? Quote Link to comment Share on other sites More sharing options...
eon Posted October 19, 2023 Share Posted October 19, 2023 18 hours ago, zaphod said: If you guys are going to update this driver is it possible to have a way to send data for variables to Control4? Currently I can send commands like http://192.168.1.12:52690/OfficeLightOn, but is there any way you could have it accept URLs like http://192.168.1.12:52690/SetVariables?Temp1=26 where Temp1 is a variable that is existing in Control4? Or something similar? Or is there another way to do this currently? You can use this driver for that. https://github.com/itsfrosty/control4-2way-web-driver/tree/master i’v been using it for couple of years to send data to control4 and chowmain tcp driver to send data from Control4 Quote Link to comment Share on other sites More sharing options...
zaphod Posted October 19, 2023 Share Posted October 19, 2023 Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.