From - RESTful Command - Home Assistant
I am trying to reproduce this python requests statement
requests.post('http://juke.local/zone_toggle.php', data={'index':1, 'id':'None', 'power':'off', 'source':3})
this is not working
juke_s4_o1:
url: http://10.10.10.13/zone_toggle.php
method: post
content_type: "application/x-www-form-urlencoded"
payload: "{'index':0, 'id':'None', 'power':'off', 'source':4}"
been doing wireshark traces, postman, and others to learn what I do not know. My guess is that this is not a true RESTful API but instead I am filling in a form??
This is the Wireshark from a python script that works
Frame 5: 104 bytes on wire (832 bits), 104 bytes captured (832 bits)
Ethernet II, Src: Apple_89:78:bc (9c:76:0e:89:78:bc), Dst: Raspberr_e5:ec:f4 (b8:27:eb:e5:ec:f4)
802.1Q Virtual LAN, PRI: 0, DEI: 0, ID: 40
Internet Protocol Version 4, Src: 10.10.10.99, Dst: 10.10.10.13
Transmission Control Protocol, Src Port: 60956, Dst Port: 80, Seq: 227, Ack: 1, Len: 34
[2 Reassembled TCP Segments (260 bytes): #4(226), #5(34)]
Hypertext Transfer Protocol
POST /zone_toggle.php HTTP/1.1\r\n
Host: juke.local\r\n
User-Agent: python-requests/2.27.1\r\n
Accept-Encoding: gzip, deflate\r\n
Accept: */*\r\n
Connection: keep-alive\r\n
Content-Length: 34\r\n
Content-Type: application/x-www-form-urlencoded\r\n
\r\n
[Full request URI: http://juke.local/zone_toggle.php]
[HTTP request 1/1]
[Response in frame: 8]
File Data: 34 bytes
HTML Form URL Encoded: application/x-www-form-urlencoded
Form item: "index" = "0"
Form item: "id" = "None"
Form item: "power" = "off"
Form item: "source" = "4"
My HA config yealds
Frame 6: 121 bytes on wire (968 bits), 121 bytes captured (968 bits)
Ethernet II, Src: Raspberr_8d:ae:be (dc:a6:32:8d:ae:be), Dst: Raspberr_e5:ec:f4 (b8:27:eb:e5:ec:f4)
802.1Q Virtual LAN, PRI: 0, DEI: 0, ID: 40
Internet Protocol Version 4, Src: 10.10.0.20, Dst: 10.10.10.13
Transmission Control Protocol, Src Port: 57524, Dst Port: 80, Seq: 229, Ack: 1, Len: 51
[2 Reassembled TCP Segments (279 bytes): #4(228), #6(51)]
Hypertext Transfer Protocol
POST /zone_toggle.php HTTP/1.1\r\n
Host: 10.10.10.13\r\n
User-Agent: HomeAssistant/2022.4.7 aiohttp/3.8.1 Python/3.9\r\n
Content-Type: application/x-www-form-urlencoded\r\n
Accept: */*\r\n
Accept-Encoding: gzip, deflate\r\n
Content-Length: 51\r\n
\r\n
[Full request URI: http://10.10.10.13/zone_toggle.php]
[HTTP request 1/1]
[Response in frame: 8]
File Data: 51 bytes
HTML Form URL Encoded: application/x-www-form-urlencoded
Form item: "{'index':0, 'id':'None', 'power':'off', 'source':4}" = ""
Thank You in advance.