home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
69.88k stars 28.98k forks source link

Genius Hub - plug status no longer visible as binary_sensor #103195

Open RogerSelwyn opened 8 months ago

RogerSelwyn commented 8 months ago

The problem

Genius Hub plugs used to appear as a binary_sensor which showed if it was on or off, and a switch which allowed the plug to be "boosted".

The binary sensor is no longer created as part of the integration, I think as a results of this PR - https://github.com/home-assistant/core/pull/102112

What version of Home Assistant Core has the issue?

core-2023.11.0

What was the last working version of Home Assistant Core?

core-2023.10.x

What type of installation are you running?

Home Assistant Supervised

Integration causing the issue

Genius Hub

Link to integration documentation on our website

https://www.home-assistant.io/integrations/geniushub/

Diagnostics information

No response

Example YAML snippet

geniushub:
  host: !secret genius_host
  username: !secret genius_username
  password: !secret

Anything in the logs that might be useful for us?

None

Additional information

No response

home-assistant[bot] commented 8 months ago

Hey there @manzanotti, mind taking a look at this issue as it has been labeled with an integration (geniushub) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `geniushub` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign geniushub` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


geniushub documentation geniushub source (message by IssueLinks)

RogerSelwyn commented 8 months ago

@GeoffAtHome could you take a look since you raised the PR?

GeoffAtHome commented 8 months ago

Will do when home in a few days.

GeoffAtHome commented 8 months ago

@RogerSelwyn the intention of PR - https://github.com/home-assistant/core/pull/102112 was to stop smart plugs appearing as switches and sensors. A switch is either "on" or "off".

Please clarify why this creates a problem for you. Sorry if I am missing the point.

RogerSelwyn commented 8 months ago

The two entities do two different things, they don’t both show the state of the plug. The binary sensor shows if the plug is on or off. The switch boosts the plug (for one hour I think). So if you enable the binary_sensor (revert to old code) then in genius app turn on the plug, you will see the binary sensor is on but the switch is off. If you turn the switch on, look in the genius app and you will see the plug has been boosted.

manzanotti commented 8 months ago

@GeoffAtHome I haven't had a chance to investigate this yet, so I don't know if this is related, but I've just done a fresh install of HA on my Pi, and neither of my smart witches are even showing in HA.

RogerSelwyn commented 8 months ago

@GeoffAtHome I haven't had a chance to investigate this yet, so I don't know if this is related, but I've just done a fresh install of HA on my Pi, and neither of my smart witches are even showing in HA.

You can try putting the old version in custom_components (as I have done) and see if they appear....

GeoffAtHome commented 8 months ago

@manzanotti PR - https://github.com/home-assistant/core/pull/102112 I see my smart plugs as switches Prior to this PR I see my smart plugs as switches and binary sensors.

@RogerSelwyn a smart plug should be a switch as it behaves like a switch. A switch is a specialised version of a binary sensor.

A switch displays the state "on" and "off". What is the value of a smart plug being displayed as both a "switch" and a "binary sensor"?

The smart plug status can be retrieved from the state of the switch.

RogerSelwyn commented 8 months ago

The smart plug status can be retrieved from the state of the switch.

Unfortunately, no it can't. As I've said before the switch does a boost (for an hour I think), it does not reflect the status of the plug (unless you've changed that and I don't think you have). The screenshot below whilst using your code. Note switch.plug_dining_room. Off in HA, on in genius Apps

Screenshot 2023-11-05 at 15 56 57

This one shows old code. App shows on, HA binary_sensor shows on, switch shows off.

Screenshot 2023-11-05 at 16 01 13
RogerSelwyn commented 8 months ago

And here I have toggled the switch in the old code. App shows boosted (it is for an hour), both entities on in HA.

Screenshot 2023-11-05 at 16 06 32
RogerSelwyn commented 8 months ago

In case it makes a difference maybe this is a bug in the way the code handles the v3 api, and that the switch should show on when it is scheduled on, but as you can see it doesn't.

If it is meant to show On, then we should look at a bug fix as well. The docs say this:

SWITCH ENTITIES

Switch entities will report back their state; other properties are available via their state attributes. Currently, HA switches do not have modes/presets, so the Home Assistant state will be reported as:

On for Override \ On, and
Off otherwise (NB: the zone could still be ‘on’, e.g., with Timer mode)

I've just always assumed it was mean to be like that, and basically ignore the switch since it is incorrect.

Just to add, if the switch is mean to turn it on. Is it meant to just Boost for an hour, or what is the expectation of what it should do?

RogerSelwyn commented 8 months ago

Sorry, I keep adding more.

The current code shows that the switch will only show on when it is overridden (boosted):

def is_on(self) -> bool:
    """Return the current state of the on/off zone.

    The zone is considered 'on' if & only if it is override/on (e.g. timer/on is 'off').
    """
    return self._zone.data["mode"] == "override" and self._zone.data["setpoint"]
manzanotti commented 8 months ago

@GeoffAtHome If I revert the change in that PR locally, I just see the smart plugs as binary sensors. Where are you seeing them duplicated?

image
GeoffAtHome commented 8 months ago

I get the following when I revert the PR: image

Smart Plugs 4, 6 and 86 are duplicates of Bedroom Socket, Kitchen Socket and Study Socket.

Note that the state of the switch/binary sensors are not is sync which is due to PR https://github.com/home-assistant/core/pull/102110

In async_setup_platform in both switch.py and binary_sensor.py the list of devices in broker.client.zone_objs is filtered to create either a switch or a binary_sensor. In my case, my smart plugs, which are old, are passing the test in switch.py and binary_sensor.py.

In my setup a smart plug identifies it self as:

type: 'Smart Plug'
state: {'outputOnOff': True }

A binary_sensor such as a single channel receiver identifies it self as:


type: 'Single Channel Receiver'
state: {'outputOnOff': True }

From this I see why my smart plugs are added as ```binary_sensors```. 

By the time the list gets to ```switch.py``` the type has been changed from type `Smart Plug` to type `on / off`. I need to find where and why this transformation is being made.

I am not sure why your are not seeing your smart plugs as switches. How are your smart plugs getting identified?
GeoffAtHome commented 8 months ago

The difference is binary_sensors.py is looking at ``broker.client.device_objsandswitches.pyis looking atbroker.client.zone_objs- This is why my switches are getting added twice and hence the need, in my case, to removed them frombinary_sensors.py```

If I could examine the how your smart plugs different from mine may shed some light on the problem.

RogerSelwyn commented 8 months ago

binary_sensor is filtering using broker.client.device_objs. switch is filtering using broker.client.zone_objs. The binary sensor is showing the state of the device. The switch is showing whether the zone is overridden or not.

I see you are trying to alter the switch to act differently, which needs to be identified as a breaking change when it gets merged since it is changing behaviour. I see this has been commented on on that PR.

Can I suggest that PR https://github.com/home-assistant/core/pull/102112 is reverted and then merged with https://github.com/home-assistant/core/pull/102110 since they are dependant on each other. As it stands, there is no entity that reliably shows whether the plug is switched on or not.

RogerSelwyn commented 8 months ago

You need to consider whether providing the status based on the zone is giving the same detail as providing based on device. What happens if a zone is configured with more than one plug (I'm not sure if that is allowed in Genius Hub). Should you still show zone status, or status of both plugs?

GeoffAtHome commented 8 months ago

@RogerSelwyn thanks for your input and discussion.

The question, to me, is what is a smart plugs?

  1. A binary sensor
  2. A switch
  3. Both

In the original implementation this was a binary sensor. This was later changed to both, which in my opinion was wrong. The PR I raised and was to change it to a switch and only a switch.

In the HG app a Zone has a date/time schedule associated with it. Unless you want the switch to come on when the heating comes on, typically the smart plug is placed in it owns zone. Sure, it is possible to place the smart plug in the same zone as the heating. It is even possible to place two smart plugs in the same zone and have these come on and off at the same time.

For most use cases people would want to smart plug to come on and off independently. Hence placing each smart plug in its own zone.

I believe I see why there was a desire to have the smart plug as both a binary sensor and a switch. Both have binary states.

A HG smart plug, when placed in a zone, can have three modes:

  1. Off
  2. Override
  3. Timed

Off is clear and well understood. Override can override to turn the switch ON or OFF Timed is a seven day schedule where the switch can be ON or OFF

The HG smart plug in HA represented as a switch should reflect the state of the switch. That is ON or OFF. The mode of the zone that the smart plug occupies can be retrieved, if required, by a service call.

Trying to reflect the state of the smart plug and mode of zone as a switch and a binary sensor does not make sense to me. The binary sensor cannot reflect the three modes. The switch should only reflect if the plug is ON or OFF.

Sorry for the ramble but I wanted to explain my rational.

If you can provide a use case where having a smart plug as both a binary sensor and a switch adds value please let me know.

RogerSelwyn commented 8 months ago

@GeoffAtHome in general I’m fine with the change but in my view as it stands it is broken because your other PR has not been merged as yet. There is currently nothing that shows the state of the plug if it has been scheduled on rather than overridden on. Your other PR mentions status is only wrong on startup, which in my view is incorrect, it is “wrong” if it hasn’t been overridden. It will switch off again when the override ends (and it isn’t schedule on).

I agree with your view on whether plugs will be grouped or not, I mentioned it because it needs to be considered before a change is made.

GeoffAtHome commented 8 months ago

What I have done is to deprecating a smart plug appearing as a binary sensor. This was made clear in https://github.com/home-assistant/core/pull/102112 . This makes no difference to the state of the plug or to whether it is or is not grouped.

RogerSelwyn commented 8 months ago

You miss my point. I'm fine that you remove that binary_sensor, but that should only be done after the switch is working properly, which it isn't. That will only be the case when PR https://github.com/home-assistant/core/pull/102110 is implemented. At the moment it is broken. The switch shows the override status, not the plug status (as you can see in your screenshot of yesterday, where you noted 102110 was the reason).

I've pretty much said the same thing multiple times now. For me I'll use the old code in custom_components until the core version is functioning again (with or without the binary_sensor, I just want something that is accurate).

GeoffAtHome commented 8 months ago

I think we are on the same page. The switch has always been wrong - 102110 should fix that. Does 102110 fix it for you?

Gowah8 commented 8 months ago

The above seems to concentrate on smart plugs. However, the Genius electric switches also used to report as binary_sensor.electric_switch. But now the Genius electric switch entities are no longer being provided by the geniushub integration. And there are no equivalent switch entities.

GeoffAtHome commented 8 months ago

@Gowah8 is you can capture the JSON returned from your hub we can include the electric switch like a smart plug.

Looking at the other products in the GH shop such as the electric relay and range extender.

The wireless room thermostat is very different from the whole house thermostat that was originally supplied to me.

Let me know if you need help capturing the JSON.

Gowah8 commented 8 months ago

No idea how to capture the JSON

On Thu, 9 Nov 2023, 4:28 pm GeoffAtHome, @.***> wrote:

@Gowah8 https://github.com/Gowah8 is you can capture the JSON returned from your hub we can include the electric switch like a smart plug.

Looking at the other products in the GH shop such as the electric relay and range extender.

The wireless room thermostat is very different from the whole house thermostat that was originally supplied to me.

Let me know if you need help capturing the JSON.

— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/103195#issuecomment-1804156025, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARPTGQHM65VEXJMWNPEODIDYDUAC5AVCNFSM6AAAAAA6ZYZDZKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBUGE2TMMBSGU . You are receiving this because you were mentioned.Message ID: @.***>

manzanotti commented 6 months ago

@Gowah8 A fix for the original issue was released in 2023.12.0, can you see if that fixes this issue too?

Gowah8 commented 6 months ago

Currently abroad hence not risking update. Will try on my return in early January.

On Sun, 17 Dec 2023, 8:35 pm Paul Manzotti, @.***> wrote:

@Gowah8 https://github.com/Gowah8 A fix for the original issue was released in 2023.12.0, can you see if that fixes this issue too?

— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/103195#issuecomment-1859174777, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARPTGQGZRXKYDR257KPZI5TYJ3YKLAVCNFSM6AAAAAA6ZYZDZKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNJZGE3TINZXG4 . You are receiving this because you were mentioned.Message ID: @.***>

Gowah8 commented 6 months ago

Have upgraded to Home Assistant 2024.1 and restarted Genius Hub. Still no entities binary_sensor.electric_switch. Also no entities binary_sensor.smart_plug

On Sun, 17 Dec 2023 at 13:35, Paul Manzotti @.***> wrote:

@Gowah8 https://github.com/Gowah8 A fix for the original issue was released in 2023.12.0, can you see if that fixes this issue too?

— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/103195#issuecomment-1859174777, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARPTGQGZRXKYDR257KPZI5TYJ3YKLAVCNFSM6AAAAAA6ZYZDZKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNJZGE3TINZXG4 . You are receiving this because you were mentioned.Message ID: @.***>

GeoffAtHome commented 6 months ago

@Gowah8 please attach the JSON for your setup so this can be investigated.

To do that head over to here and follow the instructions.

Once installed run the commands:

python ghclient.py ${HUB_ADDRESS} -u ${USERNAME} -p ${PASSWORD} zones -v
python ghclient.py ${HUB_ADDRESS} -u ${USERNAME} -p ${PASSWORD} devices -v

Replace ${HUB_ADDRESS} with your hub address I.e. 192.168.15.xxx. Same for USERNAME and PASSWORD.

TIA

Gowah8 commented 4 months ago

Finally got around to this. Attached are zones and devices outputs. Relevant switch for wet underfloor heating are KITCHEN & UTIL and FAMILY. Also attached are missing entities from Home Assistant ( note missing UFH Kitchen & Util already deleted) and Genius Hub app devices. As noted previously the UFH used to be available as binary_sensor.electric_switch but became unavaialble around Oct 2023 after HA update, Gowah8 Genius Hub zones & devices.txt Home Asistant Missing Entities Genius Hub devices

Gowah8 commented 2 months ago

GeoffAtHome. Can you help with this. Still no binary sensor for the electric switches

GeoffAtHome commented 2 months ago

@Gowah8 thanks for supplying devices.txt. I see that you have eight 'switches' (devices that support on/off).

Binary sensors are set is the type contains "Receiver". For you this is:

{"id": "3", "type": "Dual Channel Receiver", "assignedZones": [{"name": null}], "state": {"outputOnOff": true}}, 
{"id": "3-1", "type": "Dual Channel Receiver - Channel 1", "assignedZones": [{"name": "TOWER HOUSE"}], "state": {"outputOnOff": true}}
{"id": "3-2", "type": "Dual Channel Receiver - Channel 2", "assignedZones": [{"name": "Boiler Hot Water"}], "state": {"outputOnOff": false}}

The "Smart Plugs" are identified as:

{"id": "19", "type": "Smart Plug", "assignedZones": [{"name": "SMART PLUG 1"}], "state": {"outputOnOff": false}}, 
{"id": "22", "type": "Smart Plug", "assignedZones": [{"name": "SMART PLUG 2"}], "state": {"outputOnOff": false}}, 

What is have not seen before are "Electric Switch":

{"id": "5", "type": "Electric Switch", "assignedZones": [{"name": "Elec Hot Water"}], "state": {"outputOnOff": false, "measuredTemperature": 50.20000076293945}}, 
{"id": "6", "type": "Electric Switch", "assignedZones": [{"name": "FAMILY"}], "state": {"outputOnOff": false}}, 
{"id": "7", "type": "Electric Switch", "assignedZones": [{"name": "KITCHEN & UTIL"}], "state": {"outputOnOff": false}}, 

I am unclear from your comments above what is and is not working. Please confirm:

  1. Your "Dual Channel Receiver" are working.
  2. Your "Smart Plug" are working.
  3. The issues are with the "Electric Switch".
  4. Are there any other issues?

I note that one of your electrical switches has a measured temperature. Did this used be to displayed in HA?

Gowah8 commented 2 months ago

GeoffAtHome Dual Channel Receiver working Smart Plugs working Electric switches working in the Genius Hub app but not available in Home Assistant

Attached is a listing of all Genius Hub entities in my Home Assistant. Ignore Smart Plug 19 and Smart Plug 22. These are superseded entries, they now appear as switch_smart_plug_1 and switch_smart_plug_2

However, note that binary_sensor.electric_switch_5, binary_sensor.electric_switch_6 and binary_sensor.electric_switch_7 are no longer provided by the Genius Hub integration - up to late 2023 these entities were available. (note: binary_sensor.electric_switch_7 does not appear in the attached listing as I deleted it in Home Assistant in the hope it would return on reboot - it did not !). Switch 5 controls (on/off) the electric immersion heater in the hot water tank. It has a physical sensor attached that provides the temperature. Switches 6 and 7 each operate a zone valve (on/off) to control water flow into a separate zone in my wet underfloor heating.

On Sat, 20 Apr 2024 at 12:11, GeoffAtHome @.***> wrote:

@Gowah8 https://github.com/Gowah8 thanks for supplying devices.txt. I see that you have eight 'switches' (devices that support on/off).

Binary sensors are set is the type contains "Receiver". For you this is:

{"id": "3", "type": "Dual Channel Receiver", "assignedZones": [{"name": null}], "state": {"outputOnOff": true}}, {"id": "3-1", "type": "Dual Channel Receiver - Channel 1", "assignedZones": [{"name": "TOWER HOUSE"}], "state": {"outputOnOff": true}} {"id": "3-2", "type": "Dual Channel Receiver - Channel 2", "assignedZones": [{"name": "Boiler Hot Water"}], "state": {"outputOnOff": false}}

The "Smart Plugs" are identified as:

{"id": "19", "type": "Smart Plug", "assignedZones": [{"name": "SMART PLUG 1"}], "state": {"outputOnOff": false}}, {"id": "22", "type": "Smart Plug", "assignedZones": [{"name": "SMART PLUG 2"}], "state": {"outputOnOff": false}},

What is have not seen before are "Electric Switch":

{"id": "5", "type": "Electric Switch", "assignedZones": [{"name": "Elec Hot Water"}], "state": {"outputOnOff": false, "measuredTemperature": 50.20000076293945}}, {"id": "6", "type": "Electric Switch", "assignedZones": [{"name": "FAMILY"}], "state": {"outputOnOff": false}}, {"id": "7", "type": "Electric Switch", "assignedZones": [{"name": "KITCHEN & UTIL"}], "state": {"outputOnOff": false}},

I am unclear from your comments above what is and is not working. Please confirm:

  1. Your "Dual Channel Receiver" are working.
  2. Your "Smart Plug" are working.
  3. The issues are with the "Electric Switch".
  4. Are there any other issues?

I note that one of your electrical switches has a measured temperature. Did this used be to displayed in HA?

— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/103195#issuecomment-2067641166, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARPTGQFD6G3J5Y52A5POOS3Y6JEN3AVCNFSM6AAAAAA6ZYZDZKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANRXGY2DCMJWGY . You are receiving this because you were mentioned.Message ID: @.***>

GeoffAtHome commented 2 months ago

I am a little confused at the moment. I need to do my research about "Electric Switch". This is eluding me at the moment.

It is probably directly related to changing "Smart Plugs" into switches rather than just binary sensors. But I cannot see beyond that at the moment.

GeoffAtHome commented 2 months ago

OK - I can see what has happened. "Smart Plugs" must be in their own zone and the zone type must be "on / off". The electric switches can be in a zone with one or more devices and the zone type is "hot water temperature".

Now that I can see the problem need to think about a solution.

Gowah8 commented 2 days ago

GeoffAtHome Any likelihood of a solution to the missing binary sensor entities for the Genius Hub electric switches ?

GeoffAtHome commented 2 days ago

Will gladly make the necessary change but currently trying to get a different PR completed.

The delay is with me and the reviewer that has been compounded with exams and holidays... I am still travelling.