I am using HA #1 command line switch to control Device A in HA instance #2
Output is as below
{"attributes": {"friendly_name": "Projector", "icon": "mdi:television", "physical_address": "0.0.0.0", "supported_features": 384, "type": "TV", "type_id": 0, "vendor_id": 0, "vendor_name": "JVC"}, "context": {"id": "5bfcdf8babbd42d2aad5e552adbd0b0c", "parent_id": null, "user_id": null}, "entity_id": "media_player.hdmi_0", "last_changed": "2019-05-23T17:59:43.020703+00:00", "last_updated": "2019-05-23T17:59:43.020703+00:00", "state": "on"}
How do I pull the “state” so I can let the switch know the device is ON?
- platform: command_line
switches:
deviceA:
command_on: my on command
command_off: my off command
command_state: my state command
value_template: '??? what I need to know'
friendly_name: Device A
FYI
i used eventstream/statestream in past and want to try this for reliability. those worked just fine but there was occasion when mqtt server reboot and HA2 not reestablish connection. API is guarantee unless HA server down.
EDIT
below ‘value_template’ worked. thanks @VDRainer
- platform: command_line
switches:
deviceA:
command_on: my on command
command_off: my off command
command_state: my state command
value_template: '{{ value_json.state == "on" }}'
friendly_name: Device A