Ikea Tradfri State not updating

Hi,
Same thing happening a lot to me too. It’s been worse the last 2 months, but it occurred earlier as well. This morning it was out of sync so I restarted HA but this time Trådfri didn’t even start. See image attached.

How can we troubleshoot this?

I have the same issue as well.
After some hours Tradfri app and Home Assistant do not sync status. Restart Home Assistant do solve the issue for a couple of hours.

Even tried a fresh install (just Home Assistant and Tradfri) and the issue is there as well. The logs are blank…

Does anyone have a solution for this problem?

Home Assistant Ver 0.87.1

I have the same issue. Exact same symptoms. Works for a while after restarting.

hassio 0.88.1 on RPi 3

…same here, RPi 3, 0.88.1, no errors logged.

Currently no problems RPi3 0.88.1
I have an automation which restart hass 2 times in a week

Same happens to me on 0.88.1: Observation failed for tradfri bulbs

There’s an open bug: https://github.com/ggravlingen/pytradfri/issues/205

Alternative: Tradfri unstable as hell

@balloob could you please take a look at this? It would be great!
Ty!

Same problem here…very unstable and doesnt update status…also really slow.

Hi there,

short update: I tried to figure out if there is something network-related which keeps the Tradfri from updating. So i added specific rules to the Raspberry’s ufw firewall for the coap port and added a switch so the Fritzbox shouldn’t be in the way when communication with the Tradfri gateway. But in fact, this doesn’t make any difference. I still have errors logged:

2019-08-04 18:45:57 ERROR (MainThread) [homeassistant.core] Error doing job: Fatal read error on socket transport
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/asyncio/selector_events.py", line 801, in _read_ready__data_received
    data = self._sock.recv(self.max_size)
OSError: [Errno 113] No route to host

Sometimes it says “[Errno 110] Connection timed out” instead of “[Errno 113] No route to host” but it’s always selector_events.py at line 801. When pinging the gateway from the commandline, everything shows up well.

Regards,
Peter

Hi All,
My problem is similar, but still different; I have set group import to true and the Tradfri GW Groups are correctly imported into HA, but they do not get state information unless i trigger them (on/off) manually in the Lovelace interface. Each individual bulb in each group correctly shows state information.
Now, the reason I expect this to work, is because it did work correctly the first time I set up the Tradfri integration. But then a few weeks later into the project, I had to reset the GW and start over again. And since then, Groups never show state info unless triggered manually.
I have tried to delete the integration and re-initialize it, but to no avail. I have also manually deleted the groups from core.entity_registry and let HA add the groups again automatically, but they still fail to show state change.
Any ideas anyone?

Next Update: Since running 98.0 everything woorks as expected. Did regular updates on the machine via apt and updated Home Assistant - works finde now since 3 weeks, no more log entries… I have literally no idea what fixed this, because the 98.0 changelog doesn’t tell anything related to the Tradfri integration…

Sometimes it is just the restart of the tradfri hub

I don’t think so. Tradfri hub was restartet regularly while i was diagnosing the error and never made it more than 8 hours - now we have 3 weeks, so i suspect something was changed or maybe a python upgrade on my machine “fiexd” the issue…

Who is using Docker?

I went back to my docker-less install and these problems go away

The update issue when switching (TURNED-ON) lights off with a regular switch is really bogging me from the beginning of this year. I have more then 20 tradfri light devices and about 5 tradfri switches.

For long I have used the following YAML for each light:

- alias: Achtertuin update trick
  trigger:
    platform: time_pattern
    minutes: '/1'
  condition:
    condition: template
    value_template: "{{ is_state('light.achtertuin','on') }}"
  action:
    service: light.turn_on
    data_template:
      entity_id: light.achtertuin
      brightness: "{{ state_attr('light.achtertuin','brightness') | int }}"

This worked perfect for the last months. Since this week I have set this kind of trick over to node-red where it is easier to chain those tricks to avoid overloading of the tradfri gateway.

Sadly this trick is not working with the tradfri switches as there are no extra attributes to push out. I guess that the gateway is trying to be smart…

Because I have invested quit a lot in the IKEA crap I’m thinking to bring everything back but I guess customer service has no clue what we are talking about.

Z-Wave stuff is working beautifully.

Hey thanks for your idea, to solve the problem. Because i have several lights i’ve wrote an python_script (Python Service Call in HomeAssistant), that filters all lights that are state ‘on’ and sends a fake call_service to check if they are unavailable.

The code (file: update_tradfri_lights.py in config folder)

# Script: Check lights if they are still on
# Iterate through all lights
for entity_id in hass.states.entity_ids('light'):
   # Filter lights who are in state 'on'
   if hass.states.get(entity_id).state == 'on':
      # get brightness of light
      brightness_of_entity = hass.states.get(entity_id).attributes['brightness']
      # Make a Fake Service Call to update the light
      # logger.info(f"{entity_id} is {hass.states.get(entity_id).state} with brightness level of {brightness_of_entity}")
      service_data = {'entity_id': entity_id, 'brightness': brightness_of_entity}
      hass.services.call('light', 'turn_on', service_data, False)

best regards

1 Like

I gave up on this and have found that there are two scenarios that Trådfri enters when it gets unresponsive. It is not an optimal way of solving it but I got fed up that I’m not able to turn on an of lamps and that my automations got stuck due to that I was not able to read states from my entities.

Scenario 1:

Light entities enters state: unknown, none or unavailable. Choose one entity that you want to have as verification entity. I also use this for some other integrations to make sure that they get restarted when they stop working. Please note that the script for restart is below in this text.
For this scenario I made this automation:

- id: Tradfri restart
  alias: Trådfri restart
  initial_state: true
  trigger:
    - platform: template
      value_template: >
        {% if ((states('light.garderob_uppe_varmvit_lampa') == 'unknown') or (states('light.garderob_uppe_varmvit_lampa') == 'none') or (states('light.garderob_uppe_varmvit_lampa') == 'unavailable')) %}
          true
        {% else %}
          false
        {% endif %}      
      for: 00:05:00
  action:
  - service: script.starta_om_tradfri

Scenario 2:
Trådfri is working but state is not updated for entities.
First select one entity as your verification entity. Preferably it is a lamp in a wardrobe that is ok to turn on and of at a regular pattern for 1 second. Please note that the script for restart is below in this text.
For this scenario I made this automation.

- id: Restart Trådfri new
  alias: Restart Trådfri new
  initial_state: true
  trigger:
    - platform: time_pattern
      minutes: "/5"
    - entity_id: alarm_control_panel.verisure_alarm
      to: disarmed
      platform: state
  action:
    - choose:
        - conditions: 
            - condition: template
              value_template: "{{ is_state('light.garderob_uppe_varmvit_lampa', 'on') }}"
          sequence:
            - service: light.turn_off
              data:
                entity_id: light.garderob_uppe_varmvit_lampa
            - delay:
                seconds: 1
            - condition: "{{ is_state('light.garderob_uppe_varmvit_lampa', 'on') }}"
            - service: script.turn_on
              target:
                entity_id: script.starta_om_tradfri
        - conditions: 
            - condition: template
              value_template: "{{ is_state('light.garderob_uppe_varmvit_lampa', 'off') }}"
          sequence:
            - service: light.turn_on
              data:
                entity_id: light.garderob_uppe_varmvit_lampa
            - delay:
                seconds: 1
            - choose:
                - conditions: 
                    - condition: template
                      value_template: "{{ is_state('light.garderob_uppe_varmvit_lampa', 'on') }}"
                  sequence:
                    - service: light.turn_off
                      data:
                        entity_id: light.garderob_uppe_varmvit_lampa
                - conditions: 
                    - condition: template
                      value_template: "{{ is_state('light.garderob_uppe_varmvit_lampa', 'off') }}"
                  sequence:
                    - service: light.turn_off
                      data:
                        entity_id: light.garderob_uppe_varmvit_lampa
                    - service: script.turn_on
                      target:
                        entity_id: script.starta_om_tradfri

Both automations call the below script:

starta_om_tradfri:
  alias: "Starta om Trådfri"
  sequence:
    - service: homeassistant.reload_config_entry
      data:
        entry_id: 1103634c6fdc438fa50bc9a58078e8d1
      target:
        entity_id: light.badrum_nere_spot_med_vitt_spektrum_2

I hope that this temporary solution will help some of you that got fed up with that it is not working as it should.

Hi guys, I have same issue with Ikea Tradfi Integration in my Home Assistant. If a bulb was lights off with the regular switch the status remain ON also if unavailable. How to solve?
I tried all the last 3 solutions of this thread but (if I didn’t wrong) without success.
Please, help me. This driving me crazy. Thanks to all

Solution posted by Olivier1974 here: