I managed to make it work.
I dismissed the visual track for on / off so that I had no synchronization problems. It also prevents needless relay activation.
How I dit it:
globals:
- id: nanoState
type: bool
binary_sensor:
- platform: gpio
pin:
number: GPIO0
mode: INPUT_PULLUP
inverted: True
id: button_1
on_press:
then:
- lambda: |-
HTTPClient http;
http.begin("http://192.168.1.74:16021/api/v1/myauthtoken/state/on");
http.GET();
id(nanoState) = http.getString()[9] == 't';
- http_request.send:
method: PUT
url: http://192.168.1.74:16021/api/v1/myauthtoken/state
headers:
Content-Type: application/json
json: |-
root.createNestedObject("on");
root["on"]["value"] = !id(nanoState);
verify_ssl: false
I’ll be working on changing color scenes next.