Service Data:
{
“entity_id”: “remote.bed_room_hub”,
“device”: “37167279”,
“command”: “PowerOn”
}
Service Data:
{
“entity_id”: “remote.bed_room_hub”,
“device”: “37167279”,
“command”: “PowerOff”
}
The above works, but how do I get it to be in a switch?
All the switch template examples I find online incorporates Harmony’s activities into a switch.
I’m looking to just call the device & command without using harmony’s activity with a switch template.
Anyone can help with what I should include in the configuration.yaml file?
I do want a switch. just not to control my hub with a harmony activities. I want to control using a switch at the harmony device level. Harmony activities are restrictive as I can only use one activity at a time. All the switch template examples I can find, uses the harmony hub activities. The sample syntax is not applicable for what I want my switch to do.
You will have to set up input_booleans (to look like switches in the front end), and automations to call the services when the input_booleans are changed.
OK .I just read the document on input boolean but it mentions automation?
I want to manually turn on and off.
I did read up on the service call remote.send before opening a new thread. In my first post, I also tested it and it does work.
I guess I need to get that into a boolean switch? But the docs example is for automation. How do I do it manually?
You have to write an automation to trigger when the input_boolean is changed manually in the front end. The automation’s action is to call the remote.send service.
input_boolean: ### This is your switch in the front end
name: TV Power
icon: mdi:power
automation:
id: tv_power
alias: 'TV Power'
trigger:
platform: state
entity_id: input_boolean.tv_power #### Triggered by either turning on or off the input_boolen
action:
service: remote.send_command
data_template:
entity_id: remote.tv_room
device: 37167279
command:
{% if is_state(trigger.entity_id, 'on') %}
PowerOn
{% else %}
PowerOff
{% endif %}
As you can see this can get quite lengthy if you have a lot of functions. One input boolean (or input select if there are more than two states for the device) and an automation.
input_boolean: ### This is your switch in the front end
tv_power:
name: TV Power
icon: mdi:power
automation:
id: tv_power
alias: 'TV Power'
trigger:
platform: state
entity_id: input_boolean.tv_power #### Triggered by either turning on or off the input_boolen
action:
service: remote.send_command
data_template:
entity_id: remote.tv_room
device: 37167279
command:
{% if is_state(trigger.entity_id, 'on') %}
PowerOn
{% else %}
PowerOff
{% endif %}
New error.
Error loading /config/configuration.yaml: while scanning for the next token
found character ‘%’ that cannot start any token
in “/config/configuration.yaml”, line 95, column 10
Line 95 is this
command:
{% if is_state(trigger.entity_id, 'on') %} ### Line 95
PowerOn
{% else %}
PowerOff
{% endif %}
We managed to get the automation button to appear, but it doesn’t turn on/off my tv. My full code below
input_boolean: ### This is your switch in the front end
tv_power:
name: TV Power
icon: mdi:power
automation:
id: tv_power
alias: 'TV Power'
trigger:
platform: state
entity_id: input_boolean.tv_power #### Triggered by either turning on or off the input_boolen
action:
service: remote.send_command
data_template:
entity_id: remote.bed_room_hub
device: 37167279
command: >
{% if is_state(trigger.entity_id, 'on') %}
PowerOn
{% else %}
PowerOff
{% endif %}
Are you turning the automation on and off (disabling / enabling the automation) instead of switching the input boolean on and off (triggering the automation).
Oh I seeeee! Yes! There was another section called input Boolean too. Didn’t notice it earlier as it was on the lower left of my control panel.
So I leave automation on and trigger the boolean section. It works!
No problem. The example I posted earlier shows how to use an input_select (drop down list) for devices that have more than two states (e.g. TV channel select)
I am trying to make this work also but with no luck
this is my coniguration.yaml
# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:
# Text to speech
tts:
- platform: google_translate
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
input_boolean: ### This is your switch in the front end
tv_power:
name: TV Power
icon: mdi:power
automation:
id: tv_power
alias: 'TV Power'
trigger:
platform: state
entity_id: input_boolean.tv_power #### Triggered by either turning on or off the input_boolen
action:
service: remote.send_command
data_template:
entity_id: harmony_hub_studio
device: 74755884
command: >
{% if is_state(trigger.entity_id, 'on') %}
PowerOn
{% else %}
PowerOff
{% endif %}
ssdp:
homeassistant:
customize: !include customize.yaml
samsungtv:
- host: 192.168.0.18
webostv:
host: 192.168.0.30
name: Kitchen TV
turn_on_action:
service: persistent_notification.create
data:
message: "Turn on action"
customize:
sources:
- livetv
- youtube
- makotv
- netflix
notify:
# MiLight integration
light:
platform: limitlessled
bridges:
- host: 192.168.0.16
groups:
- number: 1
name: Studio 1
type: rgbww
fade: true
- number: 2
name: Studio 2
type: rgbww
fade: true
- number: 3
name: Studio 3
type: rgbww
fade: true
- number: 4
name: Studio 4
type: rgbww
fade: true
- host: 192.168.0.13
groups:
- number: 1
name: Bedroom
type: rgbww
fade: true
- number: 2
name: Bedroom 2
type: rgbww
fade: true
- number: 3
name: Bathroom
type: rgbww
fade: true
- number: 4
name: Bathroom 2
type: rgbww
fade: true
the switch shows up but does not work
I am getting error in logs saying
Invalid config for [automation]: required key not provided @ data[‘action’]. Got None. (See /Users/simonslater/.homeassistant/configuration.yaml, line 21).
action is indented way too far. It should be in line with the start of id, alias and trigger. Look at the examples in the topic above.
You may also have the issue that you are using default_config which includes automation and input_boolean already. So defining the automation and input boolean as you have may prevent you using the UI editors. Not really sure.