Harmony Elite + lamps

Hi,

I am trying to automate my Harmony remote, but I am not able to get it to work.
My idea is to turn off all the lights when I switch of an activity such as Watch TV. I can’t find the entity of the remote, so not sure what to put in there.

So the automation should start when I stop watching TV by clicking the off button on the remote. Which will end the activity Watch TV
Then it should turn of several lamps as well as dimming other lamps (stair case, bedroom and bathroom).

I am trying to write this in yaml not python or anything like that. If someone could share their configuration or how I should proceed with this, that would be much appreciated.

Cheers!

You would need to write an automation with as trigger the state of your harmony remote. For example, I called mine “family_room” thus the trigger in the automation would be:

trigger:
  - platform: state
    entity_id: remote.family_room

That would trigger the automation for each state change. Next you can then add a condition to your automation:

condition:
  condition: template
  value_template: "{{ state_attr('remote.family_room','current_activity') == 'PowerOff'

That will ensure the automation only runs if the current activity is PowerOff.
And then you can do action to call the respective services. Thus it would look like:

- alias: "Turn on lights when powering off TV".
   trigger:
     - platform: state
       entity_id: remote.family_room
   condition:
     condition: template
     value_template: "{{ state_attr('remote.family_room','current_activity') == 'PowerOff' }}"
   action:
     service: turn_lights_on

OR, you can create the trigger as a template instead and then have it like:

- alias: "Turn on lights when powering off TV".
    trigger:
      - platform: template
         value_template: "{{ state_attr('remote.family_room','current_activity') == 'PowerOff' }}"
    action:
       service: turn_lights_on

This should work, hope it helps. :slight_smile:

You need to start using code formatting rules posted at the top of the page.

@Tukun There are a number of ways to do this.

First you need to locate the entity_id that your remote has. Simply look in the states page for remote.xx

Once you have that information, post it here. Also answer these questions:

  1. Do you want it to always turn lights off when powering off at all times of the day?
  2. Do you want this automation to run when powering off every activity or just WatchTV?

Do yourself a favour and install emulated_roku, then you can write a script/scene to do what you want and add it to your Activity on your Harmony rather than making HA trigger it.

First of all, thanks to everyone that has replied.

@petro
The entity id is: remote.harmony_hub

  1. It might be ok to add a condition such as after 9pm
  2. The automation should ony run when I end the activity Watch TV

So this can be achieved in a few ways. This uses a template to look at the previous state and the state it’s going to.

- alias: Turn off light after watching TV
  trigger:
    - platform: state
      entity_id: remote.harmony_hub
  condition: # this list of conditions is 'and'ed together.
    - condition: template
      value_template: >
        {{ trigger.from_state.attributes.current_activity == 'Watch TV' and 
           trigger.to_state.attributes.current_activity == 'PowerOff' }}
    - condition: time
      after: '21:00:00' # 9 pm
  action:
    - service: light.turn_off
      entity_id: light.living_room

trigger documentation (plaftorm: state)

trigger object documentation (used in the first condition):

If you click on docs on the main page, there is a sidebar that fully covers all aspects of automations:

image

1 Like

Thanks alot!
The lamp is connected to a Fibaro wall plug. Should I still use:

- service: light.turn_off

probably switch.turn_off, if it’s a switch.

The lamp is not turning off when I am ending the Watch TV on the remote. I have change the time to 19:00 so it should trigger.

just '19:00' or '19:00:00'. Needs to be '19:00:00' to work. Also, are there any errors in the log?

Yes. It is to 19:00:00.
The log says nothing? If I click the trigger button in hass.io nothing happening either. This should turn of the activity right?

No, it will not turn off the activity. It’s an automation that is based on weather the remote turns off the activity.

are you looking in the home assistant text file in your configuration folder:

home-assistant.log

Here it is:
2018-09-26 20:01:17 ERROR (SyncWorker_3) [homeassistant.components.remote.harmony] No activity specified with turn_on service

The thing is, I can turn off the activity hence the TV by clicking the harmony off button inn Hass.io. If I run the automation “Turn off light after watching TV” it does only swith off the lamp but nothing else.

I want the lamp to be switch off when I turn off the remote\ending Watch TV from remote.
The automation is this:

- alias: Turn off light after watching TV
  trigger:
    - platform: state
      entity_id: remote.harmony_hub
  condition: # this list of conditions is 'and'ed together.
    - condition: template
      value_template: >
        {{ trigger.from_state.attributes.current_activity == 'Watch TV' and 
           trigger.to_state.attributes.current_activity == 'PowerOff' }}
    - condition: time
      after: '21:00:00' # 9 pm
  action:
    - service: switch.turn_off
      entity_id: switch.fibaro_system_blomster_lampe`

I think you have a miss interpretation of what the auotmation is doing. An automation is an automated process that runs in the background. It’s not something that you will be ‘pressing’. You pressing it only executes the actions, it does not test the condition or the trigger.

What should be happening is:

You turn off the activity via the remote. The automation is triggered and turns off the light if the conditions are met.

This error is isn’t related to the automation either. This error is related to whatever you mean by this:

Yes, I understand. But nothing is happening. The power off on the remote does not trigger the switch to turn off the lamp.

So, when logger default is set to ‘info’, it should spit out all events and services to your log. You need to check and see if home assistant see’s your events. One of the 2 conditions is not being met most likely if you are not getting errors.

That could mean 1 of 6 things:

  1. Your “Watch TV” activity has in the template has an incorrect name.
  2. Your “PowerOff” activity has in the template has an incorrect name.
  3. The time is before 9pm.
  4. The time on your operating system is set incorrectly.
  5. The timezone in your configuration.yaml is set incorrectly.
  6. The attribute inside the state object (from_state, to_state) is incorrectly named. (This is unlikely, because I verified that on my system.

When it comes to naming your activities and writing templates, the names have to have identical case, spelling, and whitespace. For example "Watch TV" does not equal "Watch Tv".

Hi again.

It works after setting correct time in Hass.io. The time was set to utc for some reason.

The next question is:
Do I need to make action for each lamp I want to switch off? Or can I continue adding it underneath this:

action:
    - service: switch.turn_off
      entity_id: switch.fibaro_system_blomster_lampe

It would then be:

  action:
    - service: switch.turn_off
      entity_id: switch.fibaro_system_blomster_lampe
   - service: lamp.turn_off
      entity_id: light.le_klint_stalampe
   - service: lamp.turn_off
      entity_id: light.light.trapp_2

I would like to dim two lamps as well. This is hue lamps.

you can combine them into 1 service:

  action:
    - service: homeassistant.turn_off
      entity_id:
        - switch.fibaro_system_blomster_lampe
        - light.le_klint_stalampe
        - light.light.trapp_2