sebr / bhyve-home-assistant

Orbit BHyve custom component for Home Assistant
MIT License
251 stars 42 forks source link

Entity states do not get updated (except when I enter the bhyve app) #197

Open Lokilicious opened 1 year ago

Lokilicious commented 1 year ago

Describe the bug Entities do not get updated. Installed the latest version (3.1.3) and re-added the integration from scratch

Example:

  1. I turn on the switch to start manual watering for a Zone
  2. Watering starts
  3. Switch stays off

When I enter the official bhyve app suddenly the correct state is reflect in home assistant 😕 (which makes no sense at all to me)

Expected behaviour Entities reflect the actual state.

BHyve devices HT25 (FW: 0041)

Device Diagnostics

config_entry-bhyve-832cc9931d0e2e4cfc2a4e8cc87fe1e8.json.txt

sebr commented 1 year ago
  1. I turn on the switch to start manual watering for a Zone

How did you turn on the switch? Was this

  1. The Home Assistant switch which is exposed
  2. Using the app
  3. Pressing the physical button on the device

Regardless, it's unfortunately hard for me to debug these types of issues... :(

Can you please turn on debug logging by adding the following to your configuration.yaml file:

logger:
  default: warning
  logs:
    custom_components.bhyve: debug

And when you are able to reproduce this issue please attach your logs. You can filter out any line which doesn't include the text custom_components.bhyve

thanks

Lokilicious commented 1 year ago

Via the Home Assistant Switch.

2023-05-28 12:25:37.log

Just noticed watering doesn't always start when using the switch, but it works if I use the HA service "Switch: Turn On" - nevertheless entity doesn't get updated

Additionally with my other Hose Tap (other Zone) it works :(

Lokilicious commented 1 year ago

Since it only happens to my 2nd bhyve faucet I was wondering if its something related to both zones being called the same in HA ("Unknown") ...

then again the entity IDs are different: switch.unknown_zone and switch.unknown_zone_2

It worked before, only since a couple of days it is acting strange.

sebr commented 1 year ago

Yes... possible. I think that bhyve changed some logic. Initially a Host Timer was required to have a zone name, even though there was a 1:1 mapping with a device. This was awkward and they probably have started to assume that the device name is sufficient to the zone name.

In the meantime, I'm going to publish a beta which sets a better zone switch name, and hopefully this helps.

I can see in your logs that when you "turn on" the switch that we are logging set_manual_preset_runtime and not actually sending a message to start watering. Can you share the entire script please?

2023-05-28 12:27:20.609 INFO (MainThread) [custom_components.bhyve.switch] set_manual_preset_runtime service called ####### <- Here i activated the watering with a script (i.e. calling the service Switch: Turn on) -- Watering started but entity was not updated
2023-05-28 12:27:20.609 DEBUG (MainThread) [custom_components.bhyve.switch] Service handler: set_manual_preset_runtime {'minutes': 45}
2023-05-28 12:27:20.609 INFO (MainThread) [custom_components.bhyve] Setting manual preset runtime: {'event': 'set_manual_preset_runtime', 'device_id': '6303a0e64f0cf99b0e67bc41', 'seconds': 2700}
2023-05-28 12:27:21.842 DEBUG (MainThread) [custom_components.bhyve.pybhyve.websocket] msg received WSMessage(type=<WSMsgType.TEXT: 1>, data='{"timestamp":"2023-05-28T10:27:21.000Z","event":"set_manual_preset_runtime","seconds":2700,"stream-id":"6e468ff9-ee4a-44a1-b358-165678a91991","client-topics":["device-clients-1"],"gateway-topic":"devices-3","device_id":"6303a0e64f0cf99b0e67bc41"}', extra='')
2023-05-28 12:27:21.842 INFO (MainThread) [custom_components.bhyve] Message received: Unknown zone - 6303a0e64f0cf99b0e67bc41 - {'timestamp': '2023-05-28T10:27:21.000Z', 'event': 'set_manual_preset_runtime', 'seconds': 2700, 'stream-id': '6e468ff9-ee4a-44a1-b358-165678a91991', 'client-topics': ['device-clients-1'], 'gateway-topic': 'devices-3', 'device_id': '6303a0e64f0cf99b0e67bc41'}
Lokilicious commented 1 year ago

Thats the Script:

alias: Micro Drip Start for X minutes
sequence:
  - service: bhyve.set_manual_preset_runtime
    data:
      entity_id: switch.unknown_zone_2
      minutes: "{{ run_time }}"
    alias: Set Orbit B-hyve run_time preset
  - delay: "00:00:10"
  - service: switch.turn_on
    data: {}
    alias: Turn on Micro-Drip
    target:
      entity_id: switch.unknown_zone_2
  - delay:
      minutes: "{{ run_time }}"
    alias: Delay for run_time
  - service: switch.turn_off
    data: {}
    alias: Turn off Micro-Drip
    target:
      entity_id: switch.unknown_zone_2
mode: restart
icon: mdi:sprinkler-variant

Thx I will try your latest change and see if it resolves the issue :)

Lokilicious commented 1 year ago

Unfortunately the problem is still there 😂

Even when I restart HA the state is wrong (it thinks watering is on)

sebr commented 1 year ago

Okay I will continue to look into it. In the meantime, you would be better off to use service: bhyve.start_watering which starts watering a zone for a specific number of minutes.

You can then avoid all that boilerplate of setting the runtime, waiting and then turning it off

yepp31 commented 1 year ago

Bonjour @sebr,

depuis quelques jours je perds la totalité des entités issues de bhyve. j'ai un modele HT25-0000 avec firmware 0041. si je veux relancer l'intégration via le bouton configurer j'obtiens un message d'erreur de type "user input malformed ......" bref plus rien ne fonctionne. merci de votre aide image

image config_entry-bhyve-9d67c2d628497fb4cf1457d213753969.json(1).txt

Lokilicious commented 1 year ago

@yepp31 you should probably create a separate issue 🙈

Lokilicious commented 1 year ago

@sebr any news here 😕

Lokilicious commented 1 year ago

@sebr bump

sebr commented 1 year ago

Sorry everyone, I'm absolutely short on time lately and haven't had any bandwidth to investigate this further. I'll do my best to carve some time out in the next couple of weeks.

ljmerza commented 1 year ago

i think the states dont update because they are bluetooth devices so the wifi hub will only communicate with them when you trigger a connect via the app. This integrtion is only grabbing the state saved to the cloud not locally so you will never be able to have the most updated state from local devices unless you connect to them directly via the bluetooth integration

sebr commented 1 year ago

i think the states dont update because they are bluetooth devices so the wifi hub will only communicate with them when you trigger a connect via the app. This integrtion is only grabbing the state saved to the cloud not locally so you will never be able to have the most updated state from local devices unless you connect to them directly via the bluetooth integration

This always used to work and I believe that it is more likely that there was a change in the websocket protocol on bhyve's end

sebr commented 1 year ago

I've started seeing the same behaviour, but have had no luck in figuring out what has changed 😞. Unfortunately the bhyve dashboard exhibits the same behaviour.

GaryOkie commented 1 year ago

So I just got a Flume and was trying to create an automation that would monitor Water GPM per ZONE and issue an alert if any exceeded its normal volume. (I've had several blown heads flood the yard and street). There is a wide variance on GPM from the smallest to the largest zone, so ideally I need to set a GPM threshold for each, not an overall maximum.

Problem is - it appears this may not be possible if I can't have automations trigger reliably on each zone switch starting from B-Hyve programs.

ljmerza commented 1 year ago

I've started seeing the same behaviour, but have had no luck in figuring out what has changed 😞. Unfortunately the bhyve dashboard exhibits the same behaviour.

it actually looks to be working on the dashboard

image image
NotSteveAtGithub commented 2 months ago

I have a configuration in HA where the local calendar triggers NodeRed to start and stop watering during the night. I woke up this morning to find that my triggers fired but the watering may or may not have happened. After some manual triggering from the HA UI, I noticed the states not updating, but then I opened the phone app and suddenly the HA UI updated. I searched issues and found this where others have experienced this for quite awhile.

Realizing it's been most of a year since the last comments... any new insights? I love this integration but am unsure how to make it behave reliably. Thanks for all the efforts to date!