Power control media based on TV state

Turn on/off background lights ('ambilight') to my TV - and turn on rpi3

When the TV goes off during off-hours, shutdown the rPi and kill its power. The kill power subflow calls the Kodi http Api and sends'application.quit'

[{"id":"843ebd5f.85b96","type":"subflow","name":"Shutdown Kodi en power","info":"","category":"","in":[{"x":50,"y":30,"wires":[{"id":"f0c04c8e.3ad4a"}]}],"out":[]},{"id":"f0c04c8e.3ad4a","type":"http request","z":"843ebd5f.85b96","name":"shutdown kodi gracefuly","method":"GET","ret":"txt","url":"http://192.168.1.9:8080/jsonrpc?request={\"jsonrpc\":%20\"2.0\",%20\"id\":%201,%20\"method\":\"Application.Quit\"}","tls":"","x":310,"y":80,"wires":[["d806ff68.0662b"]]},{"id":"6ccdd8f5.9af888","type":"api-call-service","z":"843ebd5f.85b96","name":"turn off hs100","server":"181266bf.748f49","service_domain":"switch","service":"turn_off","data":"{\"entity_id\":\"switch.hs100\"}","render_data":false,"mergecontext":"","output_location":"payload","output_location_type":"msg","x":700,"y":80,"wires":[[]]},{"id":"d806ff68.0662b","type":"delay","z":"843ebd5f.85b96","name":"","pauseType":"rate","timeout":"2","timeoutUnits":"minutes","rate":"1","nbRateUnits":"1","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":510,"y":80,"wires":[["6ccdd8f5.9af888"]]},{"id":"9acfbf94.bcfbf","type":"tab","label":"Media","disabled":false,"info":"hier woonkamer power en het licht schema beheren"},{"id":"c5f5ddc8.14f83","type":"server-state-changed","z":"9acfbf94.bcfbf","name":"tv state","server":"181266bf.748f49","entityidfilter":"media_player.sony_bravia_tv","entityidfiltertype":"exact","outputinitially":false,"state_type":"habool","haltifstate":"","halt_if_type":"","halt_if_compare":"is","outputs":1,"x":90,"y":280,"wires":[["4ded5747.091518"]]},{"id":"4ded5747.091518","type":"switch","z":"9acfbf94.bcfbf","name":"TV on true/false?","property":"payload","propertyType":"msg","rules":[{"t":"true"},{"t":"false"}],"checkall":"true","repair":false,"outputs":2,"x":290,"y":280,"wires":[["679f4f2e.7473d","7a159e1a.0a077","c5bb6aa7.4bf3b8"],["7cce3504.ec1c2c","3826c20f.b0e2de"]]},{"id":"679f4f2e.7473d","type":"api-call-service","z":"9acfbf94.bcfbf","name":"Ambilight aan","server":"181266bf.748f49","service_domain":"hue","service":"hue_activate_scene","data":"{   \"group_name\": \"ambilight\",   \"scene_name\": \"tv\" }","render_data":false,"mergecontext":"","output_location":"payload","output_location_type":"msg","x":300,"y":180,"wires":[[]]},{"id":"7cce3504.ec1c2c","type":"api-call-service","z":"9acfbf94.bcfbf","name":"Ambilight off","server":"181266bf.748f49","service_domain":"light","service":"turn_off","data":"{\"entity_id\":\"Light.Hue_color_light_links, Light.Hue_color_light_rechts\"}","render_data":false,"mergecontext":"","output_location":"payload","output_location_type":"msg","x":310,"y":360,"wires":[[]]},{"id":"7c58c02f.a85a7","type":"stoptimer","z":"9acfbf94.bcfbf","duration":"30","units":"Minute","payloadtype":"num","payloadval":"0","name":"wait 30 min","x":730,"y":280,"wires":[["8139bf20.92c76"],[]]},{"id":"7a159e1a.0a077","type":"change","z":"9acfbf94.bcfbf","name":"send stop timer","rules":[{"t":"set","p":"payload","pt":"msg","to":"STOP","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":240,"wires":[["7c58c02f.a85a7"]]},{"id":"c5bb6aa7.4bf3b8","type":"api-call-service","z":"9acfbf94.bcfbf","name":"turn on hs100","server":"181266bf.748f49","service_domain":"switch","service":"turn_on","data":"{\"entity_id\":\"switch.hs100\"}","render_data":false,"mergecontext":"","output_location":"payload","output_location_type":"msg","x":280,"y":220,"wires":[[]]},{"id":"8139bf20.92c76","type":"subflow:843ebd5f.85b96","z":"9acfbf94.bcfbf","name":"Shutdown Kodi","x":900,"y":240,"wires":[]},{"id":"2e960d3d.a03772","type":"comment","z":"9acfbf94.bcfbf","name":"TV on = ambilight on and rPi3 on","info":"","x":170,"y":140,"wires":[]},{"id":"3826c20f.b0e2de","type":"time-range-switch","z":"9acfbf94.bcfbf","name":"","lat":"","lon":"","startTime":"13:00","endTime":"23:00","startOffset":0,"endOffset":0,"x":530,"y":300,"wires":[[],["7c58c02f.a85a7"]]},{"id":"99caeb52.703068","type":"comment","z":"9acfbf94.bcfbf","name":"Turn off rPi if TV off, except end of the day","info":"","x":600,"y":200,"wires":[]},{"id":"181266bf.748f49","type":"server","z":"","name":"Home Assistant","legacy":false,"hassio":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open"}]

Flow Info

Created 6 years, 9 months ago
Rating: not yet rated

Actions

Rate:

Node Types

Core
  • change (x1)
  • comment (x2)
  • delay (x1)
  • http request (x1)
  • switch (x1)
Other

Tags

  • kodi
  • http
  • homeassistant
  • hue
  • bravia
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option