Help needed: Homematic UI Toggle flips back

Hello,

i am new to Home Assistant and want to use my Homematic-installation with it.

When i use the UI of Home Assistant to turn on a light, the UI-Control turns on, the light turns on and then the UI Control toggles back to Off.

Reloading Home Assistant in the Browser does not help. I guess there is something wrong with my configuration:

homematic:
  hosts:
    homegear:
      ip: 127.0.0.1
      resolvenames: metadata

My installation: homematic USB-Adapter <-> homegear <-> Home Assistant 0.35.3
Running all on Raspberry PI

How can i “debug” this Problem? What i am missing?

That’s odd. What specific HomeMatic device are you using?

The only scenario where I could imagine HASS behaving like this would be, if you restart Homegear while HASS is running and not restarting HASS to re-initialize the connection (which can also be done while HASS is running using the homematic.reconnect service).
Which method did you use to reload HASS? homeassistant.reload_core_config is not sufficient, since it does not reconnect. homeassistant.restart would be the service you have to use to make sure communication with Homegear is working.

i have a running FHEM Version. For testing i stop fhem, start homegear wait until homegear shows the devices in the webinterface and finally start homeassistant.

Devices i have testet:

  • HM-LC-Dim1TPBU-FM
  • HM-LC-Sw1PBU-FM
  • HM-LC-Sw1-Pl-2

With “reloading homeassistant” i mean reloading the webinterface in the webbrowser does not help, not restarting with homeassistant.restart or reload_core_config

homeassistant.restart does not change the state of the UI.

Do you think it is more a homegear problem than homeassistant? Or how should i try to search for the problem?

Reloading the UI does not help. It’s just a representation of the internal states, so if a swich flips back, that’s the internal state. The question would be why this is happening.

It could be, that the events Homegear sends to HASS don’t arrive or are somehow corrupt. This would be a problem specific to your setup, since other users using Homegear haven’t reported such problems.

To find out what’s happening, you can set the logging for HASS to be more verbose. Something like this would show more about what’s happening in the inside:

default: warn
logs:
  homeassistant.components.homematic: debug
  pyhomematic: debug

Since you still have fhem running paralle that might also be the source of the issue. It’s been a while since I’ve last used fhem, but I remember that there was some sort of ID you had to configure for the “hub”, which was something like a 6 digit hex string. I don’t know if that’s relevant, but maybe Homegear and fhem collide because of this, even though fhem is stopped.

Anyway, with the log-configuration from above you shoud actually see all the events that arrive at HASS. And our HomeMatic implementation is designed to set the state of HASS entities based on the events we receive from Homegear, since we don’t want to rely on how the state should be, but instead on what Homegear reports the current state is.

So have a look at what’s happening with extended logging and maybe post some of that data so I can have a look at it.

With that logger setting i get:

INFO:homeassistant.components.http:Serving /api/services/homeassistant/turn_on to 192.168.1.42 (auth: True)
INFO:homeassistant.core:Bus:Handling <Event call_service[L]: service_data=entity_id=switch.alichtrechner, service_call_id=3050998864-1, service=turn_on, domain=homeassistant>
INFO:homeassistant.core:Bus:Handling <Event call_service[L]: service_data=entity_id=['switch.alichtrechner'], service_call_id=3050998864-2, service=turn_on, domain=switch>
DEBUG:pyhomematic.devicetypes.generic:HMGeneric.setValue: key = 'STATE' value = 'True'
INFO:homeassistant.core:Bus:Handling <Event service_executed[L]: service_call_id=3050998864-2>
INFO:homeassistant.core:Bus:Handling <Event service_executed[L]: service_call_id=3050998864-1>

A.LichtRechner is a “HM-LC-Sw1PBU-FM”. What i notice is that the log shows “switch.alichtrechner” but in homegear and the Homeassistant UI the Devicename is shown as A.LichtRechner" (with camelcase and a “.”).

Can my naming of the devices affect the behaviour?

If the “6 digit hex string” would be the issue the light would not be turned on, so i don’t think that there is a problem with it.

I’ve just tried this out, and after the second Event service_executed I get a log message that looks like this:

INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=switch.meq123456, old_state=<state switch.meq123456=off; ID=MEQ123456, proxy=hmrf, friendly_name=Luefter, RSSI=-58, Working=No @ 2017-01-21T10:07:06.139759+01:00>, new_state=<state switch.meq123456=on; ID=MEQ123456, proxy=hmrf, friendly_name=Luefter, RSSI=-58, Working=No @ 2017-01-21T11:06:51.895193+01:00>>

This is the event that sets HASS’ internal state. Since your log doesn’t have that: did this event not happen, or did you just not copy that? I don’t have debug enabled, but before the line I’ve posted there should also be a message that looks something like:

DEBUG:pyhomematic.devicetypes.generic:HMGeneric.event: address=MEQ123456, interface_id=homeassistant-hmrf, key=STATE, value=True

This would be the message the HomeMatic library creates when it receives an event from Homegear.

The internal name is automatically generated and should not be a problem. But it sure is worth a try to see how everything behaves if you don’t use the option to resolve names. Internally only the real device ID (MEQ123456) is being used. But maybe there’s some kind of bug related to that that never has occurred until now In that case my first guess would be, that the “.” in the name is the problem. HASS uses the “.” as a separator, like in hostnames/domains.

i tried renaming devices and various other things. And now i am at this point:

start homegear
start homeassistant
“Flipping Problem”

call homematic.reconnect
ALL OK

Stopping homeassistant
starting homeassistant
“Flipping Problem”

call homematic.reconnect
ALL OK

So when i call homematic.reconnect after startup of homeassistant it works!

But i think it should work without calling homematic.reconnect after startup…

Have a look at the Homegear logs. Apparently, the connection between HASS and Homegear drops for some reason. While starting up the connection seems to be available, because otherwise HASS wouldn’t receive the list of devices Homegear is controlling. So the connection drop happens after HASS has finished loading. We don’t / can’t detect that in HASS, but maybe the Homegear logs help.

Besides, which version of Homegear are you using?

There seems to be a bug in the latest Homegear version that may be directly related to your problem. Here’s the issue on github: Issue #270

1 Like