Automation for Ikea Tradfri Dimmer

Hey there,

I’m new to HA and try to configure an Ikea Tradfri wireless dimmer to control one ceiling light.
Since my Json and Yaml skills are none existent, I’m failing miserably.
Could someone have a look why nothing happens? The script gets triggered, but the brightness doesn’t change.

Thanks in advance! :slight_smile:

- id: '1541714862043'
  alias: Tradfri Dimmer
  trigger:
  - entity_id: sensor.0x000b57fffe2ccfd8
    platform: state
  action:
    service: light.turn_on
    entity_id: light.flur_unten
    data_template:
      entity_id: >
        {% if is_state('sensor.0x000b57fffe2ccfd8', '0') %}
          {"state":"OFF"}
        {% else %}
          {"state":"ON","brightness": {{ states("sensor.0x000b57fffe2ccfd8") | int }} }
        {% endif %}`

I think what you’re looking for is:

- alias: Tradfri Dimmer off
  trigger:
    platform: state
    entity_id: sensor.0x000b57fffe2ccfd8
  condition:
    condition: template
    value_template: "{{ trigger.to_state.state|int == 0 }}"
  action:
    service: light.turn_off
    entity_id: light.flur_unten
- alias: Tradfri Dimmer on
  trigger:
    platform: state
    entity_id: sensor.0x000b57fffe2ccfd8
  condition:
    condition: template
    value_template: "{{ trigger.to_state.state|int != 0 }}"
  action:
    service: light.turn_on
    entity_id: light.flur_unten
    data_template:
      brightness: "{{ trigger.to_state.state|int }}"
2 Likes

Thank you so much, that worked great!

2 Likes

Sorry to jump on this thread, but does this mean that hassio can use the tradfri remotes to control any device?

I was under the impression that they didn’t really have any control. As in, they communicated directly with the tradfri bulb??

I don’t have a sensor from the ikea tradfri in my HA, but I do see that events are triggered when the dimmer is rotating. What now?

When you connect the dimmer/remote with the bulp they communicate directly. When you connect both to your zigbee gateway they are both available in Home Assistant. Therefor you can do what ever you want with your dimmer or remote.

I recommend installing node-red to hassio because home assistant automation gets complicated quickly.

I control my Sonos with it to be able to put it on/off, volume control and rotate to (in this case) 3 radio stations, the tradfri. is connectes by a deconz conbee 2:

short press 1 : if radio is off, turn on if already playing volume + 5%
long press 1 : change radio station
short press 1 : volume down 5%
long press 1 : pause playing

 
- id: '1605543313862'
  alias: Operate sonos Single 1 by remote
  description: ''
  trigger:
  - platform: event
    event_type: deconz_event
    event_data:
      id: sw_sonos_single1
  condition: []
  action:
  - choose:
    - conditions:
      - condition: not
        conditions:
        - condition: state
          entity_id: media_player.sonos_single1
          state: playing
      - condition: template
        value_template: '{{ trigger.event.data.event == 1002 }}'
      sequence:
      - service: media_player.media_play
        data: {}
        entity_id: media_player.sonos_single1
    - conditions:
      - condition: state
        entity_id: media_player.sonos_single1
        state: playing
      - condition: template
        value_template: '{{ trigger.event.data.event == 1002 }}'
      sequence:
      - service: media_player.volume_set
        data_template:
          volume_level: '{{ states.media_player.sonos_single1.attributes.volume_level
            + 0.05 | float }}'
        entity_id: media_player.sonos_single1
    - conditions:
      - condition: state
        entity_id: media_player.sonos_single1
        state: playing
      - condition: template
        value_template: '{{ trigger.event.data.event == 2002 }}'
      sequence:
      - service: media_player.volume_set
        data_template:
          volume_level: '{{ states.media_player.sonos_single1.attributes.volume_level
            - 0.05 | float }}'
        entity_id: media_player.sonos_single1
    - conditions:
      - condition: state
        entity_id: media_player.sonos_single1
        state: playing
      - condition: template
        value_template: '{{ trigger.event.data.event == 2001 }}'
      sequence:
      - service: media_player.media_pause
        data: {}
        entity_id: media_player.sonos_single1
    - conditions:
      - condition: state
        entity_id: media_player.sonos_single1
        state: playing
      - condition: template
        value_template: '{{ trigger.event.data.event == 1001 }}'
      sequence:
      - entity_id: media_player.sonos_single1
        service: media_player.select_source
        data_template:
          source: >-
            {% set curSource = state_attr('media_player.sonos_single1','source') %}
            {% if curSource == 'VRT Studio Brussel' %}
              Willy Radio
           {% elif curSource == 'Willy Radio' %}
             VRT Radio 2 Limburg
           {% else %}
             VRT Studio Brussel
           {% endif %}
    default: []
  mode: queued
  max: 10
2 Likes