Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95482

Ambibox Lightpack rest command switch - SOLVED

$
0
0

@badnimits wrote:

I came up with this solution to control ambibox(lightpack.py wasn’t working nor any other solution).

the basic solution:

add this to configuration.yaml:

rest_command:
  tvled_on:
    url: 'http://127.0.0.1:8088/'
    method: POST
    payload: 'status=on'
  tvled_off:
    url: 'http://127.0.0.1:8088/'
    method: POST
    payload: 'status=off'

Add a template switch:

switch:
  - platform: template
    switches:
      tv_led:
        friendly_name: Ambilight
        icon_template: mdi:led-outline
        value_template: '{{ "on" if is_state("sensor.tvled_state", "on") else "off" }}'
        turn_on:
          service: rest_command.tvled_on
        turn_off:
          service: rest_command.tvled_off

add this sensor:


sensor:
  - platform: tcp
    name: tvled_state
    host: 127.0.0.1
    port: 3636
    payload: "getstatus\n"
    value_template: "{{ value.split(':')[2] }}"

if you only use it through HA and dont need updates you’re done.

if youd like to get status for the switch from api then use this solution:

I was finding that the switch (sometimes I turn it off from the interface not HA) was not updating properly and that the sensor is not consecutive so my solution was to add an input boolean thats triggered by the switch and sensor through automation:

configuration.yaml(add the rest command and sensor same as above):


switch:
  - platform: template
    switches:
      tv_led:
        friendly_name: Ambilight
        icon_template: mdi:led-outline
        value_template: '{{ is_state("input_boolean.ledstateboolean", "on") }}'
        turn_on:
          service: script.ledonscript
        turn_off:
          service: script.ledoffscript

input_boolean:
  ledstateboolean:
    name: led_stateboolean
    initial: off

scripts.yaml:

'ledoffscript':
  alias: LED off Script
  sequence:
  - data: {}
    service: rest_command.tvled_off
  - data:
      entity_id: input_boolean.ledstateboolean
    service: input_boolean.turn_off
'ledonscript':
  alias: LED on Script
  sequence:
  - data: {}
    service: rest_command.tvled_on
  - data:
      entity_id: input_boolean.ledstateboolean
    service: input_boolean.turn_on

automations.yaml:

- id: '1573611111585'
  alias: tvled_bool_on
  trigger:
  - entity_id: sensor.tvled_state
    platform: state
    to: 'on'
  condition: []
  action:
  - data:
      entity_id: input_boolean.ledstateboolean
    service: input_boolean.turn_on
- id: '1573611111123'
  alias: tvled_bool_off
  trigger:
  - entity_id: sensor.tvled_state
    platform: state
    to: 'off'
  condition: []
  action:
  - data:
      entity_id: input_boolean.ledstateboolean
    service: input_boolean.turn_off

enjoy.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 95482

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>