Jump to content
C4 Forums | Control4

Chowmain - Generic TCP Command Driver


alanchow

Recommended Posts

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

Link to comment
Share on other sites

  • 8 months later...

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&ampContent-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?

 

Link to comment
Share on other sites

  • 2 months later...
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&ampContent-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

Link to comment
Share on other sites

  • 7 months later...

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

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

Guest
Reply to this topic...

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

Important Information

By using this site, you agree to our Terms of Use.