|My First Automation - Driving me a little nuts

Hi,

I’m trying to setup an automation that triggers my Harmony to start an activity when a chromecast audio starts streaming but when i check the config i get

“Invalid config for [automation]: expected str for dictionary value @ data[‘trigger’][1][‘from’]. Got None
extra keys not allowed @ data[‘action’][0][‘activity’]. Got None. (See /config/configuration.yaml, line 21). Please check the docs at https://home-assistant.io/integrations/automation/

I’ve been at it for the past few days but I’m at a loss, can some nice person give it the once over and give me some hints

Current automations.yaml

- id: '1578158996958'
  alias: Stereo ON Chromecast stream active
  description: Turn on the Living-room Stereo when chromecast audio goes active
  trigger:
  - entity_id: media_player.living_room
    from: idle
    platform: state
    to: playing
  - entity_id: media_player.living_room
    from: off
    platform: state
    to: playing
  
  action:
  - entity_id: remote.living_room
    service: remote.send_command
    activity: stream music

Please re-post your automation with proper formatting.

1 Like

First of all, I agree with @pnbruckner. It is much easier to help when your configuration is formatted properly.

Based on what you have, I do have a couple hints though. For one, I always put my states in quotes. So instead of to: playing I would do to: “playing” for example. In addition, I would move the platform in your triggers above the from: portion. I’m not sure if these matter, but for me its a matter of keeping things consistent.

Also, where is your remote domain coming from? I’m not familiar with that domain of services.

It took me a while to work out what was needed,the message that pops up didnt help but this post helped @finity thanks for the help

The message you are seeing is what I usually get when I have an error in an automation. The error says configuration.yaml because that line mentioned is where your config calls all of your automations. Sometimes it will give the error location in the automations.yaml though.

OK some progress excellent , Ive made the changes you suggested and the errors changed (see below) what’s weird is the code that i had originally was created by the GUI automation editor in hassio, though I have added the activity line which now seems to be the issue

Invalid config for [automation]: [activity] is an invalid option for [automation]. Check: automation->action->0->activity. (See /config/configuration.yaml, line 21). Please check the docs at https://home-assistant.io/integrations/automation/

If I don’t include the activity line im not sure how I tell the Harmony remote what to fire up

Oh and i think i get what your asking , the remote domain comes from the Harmony integration

Progress is great! I’m only about a month into HA myself, so I’ve been asking for a lot of help.

Like I said, I’m not familiar with the remote domain. Go into developer tools, and under the services tab find remote.send_command. What are the input values that it says are required?

ok it seems i may have used the wrong “remote.” command as the one that accepts activity is remote.turn_on

However as the error says “Invalid config for [automation]: [activity] is an invalid option for [automation].” it seems i cant use it to call an activity here. Hmmm would a scene work do you think as i could trigger a scene that turns on the stereo.Its a it of a fudge

I would try something like this before messing with scenes:

action:
  - service: remote.turn_on
    entity_id: remote.bed_room_hub
    data:
       activity: "Watch TV"

OOH OOH OOH the checker says I’m valid, I can’t check as my wife’s watching Celeb Bakeoff.

I’ll test as soon as I can and respond as I’m sure you’ll be on the edge of your seat :slight_smile:

Thanks for formatting it!

This is because, in the second trigger, this line:

    from: off

contains a YAML keyword – off – which will automatically be converted to False, which is a bool, not a str. That is why states are usually quoted. The others are ok as is because they are not special YAML keywords, but it’s usually better to get into the habit of quoting the states anyway. So at least you need to change it to:

    from: 'off'

And, yes, as others have already said, your service call is invalid. At the very least you would have needed to indent activity under data. But assuming the service was wrong, too, and should have been remote.turn_on (I don’t use remote either, so I don’t really know), the action should have been:

  action:
  - entity_id: remote.living_room
    service: remote.turn_on
    data:
      activity: stream music

And, BTW, just in case you didn’t know, for a service call, entity_id is treated specially. Normally it would go under data, like this:

    service: XXX
    data:
      entity_id: YYY

but if it is lined up with service, like this:

    service: XXX
    entity_id: YYY

that’s ok, too. It’s allowed as a shortcut. The Automation & Script editors usually put it under data.

Ok so no errors showing when i check the config but i find the below in the logs when i trigger the automation

Invalid data for call_service at pos 1: required key not provided @ data[‘command’]

You need to read the docs on the turn off and send command services and decide which you should use, and then provide the necessary parameters.

Hi Thanks I’ve already made the switch to remote.turn_on as I noticed (after prompting from bookandrelease) this doesn’t accept the ‘activity’ variable,

The code i have now is

- id: '1578158996958'
  alias: Stereo ON Chromecast stream active
  description: Turn on the Living-room Stereo when chromecast audio goes active
  trigger:
  - entity_id: media_player.living_room
    platform: state
    from: "idle"
    to: "playing"
  - entity_id: media_player.living_room
    platform: state
    from: "off"
    to: "playing"
  
  action:
  - service: remote.turn_on
    entity_id: remote.living_room
    data:
       activity: "Stream music"

If i ttrigger it i get “Error while executing automation automation.stereo_on_chromecast_stream_active. Invalid data for call_service at pos 1: required key not provided @ data[‘command’]” Im googling as i speak

Are you sure you’re restarting HA (or at least reloading automations) after you change the automation? According to the docs remote.turn_on doesn’t take a command parameter, remote.send_command does.

From what I’m reading in the Harmony Hub Integration page, you need to check the configuration file for the valid activities. Check in the harmony_REMOTENAME.conf file to see what activities are options for your device.

Yeah Ive been in that and the activity names are ones i set when setting up the hub so i know they are right

Do the activities have IDs? I would try using those for simplicity and not having to worry about strings of text.

Dammit we are all done ITS WORKING :smiley: many thanks for the persistence

I stopped using the code a while back as i thought that was causing problems and just didn’t think to try it again

Thanks both for the help, i have learnt a ton.