jheling / freeathome

Free@Home component for Home Assistant
103 stars 37 forks source link

Binary sensor doesn't work #81

Closed JvD12 closed 3 years ago

JvD12 commented 3 years ago

It looks like binary sensors does not work as intended. My 2 channel digital input is detected in Home Assistant but the entity names are strange, the first is called binary_sensor. and the second binary_sensor.2 Looks like something went wrong with naming.

I'm also not able to link one of free@home entities in Node Red. They are not visible/selectable in the list.

Tho85 commented 3 years ago

Could you send a dump of your config file as described in the README, and the serial number of the devices that are not working as expected?

JvD12 commented 3 years ago

Hi, I created the dump: https://paste.ubuntu.com/p/vNcKj966Yz The serial number of the device is ABB291E72051

Do you also have suggestions/ideas for Node Red integration?

Tho85 commented 3 years ago

Hi, I've used your config and ran it through the component. For me, the generated device names are binary_sensor.hvac and binary_sensor.bel. Could you try to remove the entities in Home Assistant under "Settings" -> "Entities" and restart Home Assistant? This should re-add the device and hopefully set a correct name.

I don't use Node-RED, so unfortunately I can't help with that.

Regarding other suggestions: The binary sensors will not work as you expect. This is not (only) due to the implementation in this component, but due to the firmware on the devices themselves. They track the state (on/off) of the devices they control internally, and so if you switch the devices through Home Assistant, the device will not know, and the state will be out of sync. I haven't found a stable configuration for this yet.

Here's how I control devices in Home Assistant through my in-wall switches: I configured the emulated_hue component, so that Home Assistant works as a Philips Hue bridge, and exposed some lights through it. I then added that Hue bridge to free@home, and the exposed lights showed up in free@home. I can then link my in-wall switches with the virtual Hue light bulbs and control them. Maybe you want to try something similar instead of reading the sensor values directly?

JvD12 commented 3 years ago

Hi, thanks for the fast support! I forgot to "revert" some changes in the names. I had renamed the channels Ⓐ, ⓑ to hvac and bel. Can you test a new log also with the original naming? https://paste.ubuntu.com/p/2mvGWHr58h/

I have restarted the Free@home access point and Home Assistant systems several times without success.

Tho85 commented 3 years ago

This is most probably an issue with Home Assistant core. If you name an entity Ⓐ or ⓑ, Home Assistant tries to make an alphanumeric entity name out of this, which fails. This also occurs if you create a new automation and name it Ⓐ - this will lead to an error: homeassistant.exceptions.HomeAssistantError: Invalid entity id: automation.

Maybe this can be fixed in HA core? I'll check. Quick workaround for this component for now is to just rename your devices ;-)

EnricoBilla commented 3 years ago

From what I've seen in this regex it's only possible to use lowercase letters, digits and underscores

Tho85 commented 3 years ago

I think the relevant code is here (slugify). Here is the corresponding test. IMO it should return _ if the string is empty after slugifying.

EnricoBilla commented 3 years ago

Yes you are right👍🏼

Tho85 commented 3 years ago

I've opened an upstream PR, let's see how it turns out: home-assistant/core#43153

miezie commented 3 years ago

I'm also not able to link one of free@home entities in Node Red. They are not visible/selectable in the list.

I checked my Node Red installation and noticed that I can just use the F@H components there. Eg. when I select a "Call Service" node I can just select F@H components in the dropdown. So it might be your configuration or set-up not working.

JvD12 commented 3 years ago

Thanks for the support. I will test it next week.

JvD12 commented 3 years ago

With the renamed Free@Home devices it works as expected.

I also tested the Node Red intergration. None of the Free@Home entities are shown in the Entity ID list of Node Red. But If I put manually the correct entity name it works as intended. The Free@Home devices are visible in the Home Assistant entities ( configuration > entities) So I don't know were the problem occurs but with this manual workaround it fine for me.