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

Command line switch value_template not updating

$
0
0

@Vinz87 wrote:

switch:
  - platform: command_line
    switches:
      meross_xmas_tree:
        friendly_name: Albero 1
        command_on: "..."
        command_off: "..."
        command_state: ""
        value_template: "{{ is_state('sensor.meross_xmas_tree', 'on') }}"

I have this command line switch which I use to trigger two shell commands to turn on and off a Meross smart plug.
The shell commands write also “on” or “off” in a text file, to which is pointed a file sensor:

sensor:
  - platform: file
    name: meross_xmas_tree
    file_path: "/home/homeassistant/.homeassistant/python_scripts/meross_xmas_tree.txt"

The value_template of switch.meros_xmas_tree is linked to sensor.meros_xmas_tree, thus showing the current state of the plug.
This works great inside Home Assistant. But the problem is that the value_template seems to update only if I toggle the switch from the Home Assistant UI.
If, instead, the shell commands are execute somewhere else, the text file is updated correctly, sensor.meros_xmas_tree is updated correctly, but switch.meros_xmas_tree is not updated and is therefore out of sync with the physical state of the plug and, more surprisingly, with its own value_template.

So what I’m missing? Why value_template doesn’t get updated (without manually toggling the switch) if sensor.meros_xmas_tree does?

Posts: 4

Participants: 3

Read full topic


Viewing all articles
Browse latest Browse all 96121

Trending Articles



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