blakeblackshear / frigate-hass-integration

Frigate integration for Home Assistant
MIT License
657 stars 110 forks source link

Adding debug: true to Home Assistant 2024.5.0b0 generates Exception in _state_message_received errors #667

Closed pdobrien3 closed 2 months ago

pdobrien3 commented 2 months ago

Version of the custom_component

5.1.0

Configuration


Logger: homeassistant.util.logging
Source: util/logging.py:98
First occurred: 6:45:40 AM (10 occurrences)
Last logged: 6:45:41 AM

Exception in _state_message_received when handling msg on 'frigate/camera/recordings/state': 'ON' Traceback (most recent call last): File "/config/custom_components/frigate/camera.py", line 241, in _state_message_received self._attr_is_recording = msg.payload.decode("utf-8") == "ON" ^^^^^^^^^^^^^^^^^^ AttributeError: 'str' object has no attribute 'decode'. Did you mean: 'encode'?
Exception in _motion_message_received when handling msg on 'frigate/camera_2/motion/state': 'ON' Traceback (most recent call last): File "/config/custom_components/frigate/camera.py", line 247, in _motion_message_received self._attr_motion_detection_enabled = msg.payload.decode("utf-8") == "ON" ^^^^^^^^^^^^^^^^^^ AttributeError: 'str' object has no attribute 'decode'. Did you mean: 'encode'?
Exception in _state_message_received when handling msg on 'frigate/camera_2/recordings/state': 'ON' Traceback (most recent call last): File "/config/custom_components/frigate/camera.py", line 241, in _state_message_received self._attr_is_recording = msg.payload.decode("utf-8") == "ON" ^^^^^^^^^^^^^^^^^^ AttributeError: 'str' object has no attribute 'decode'. Did you mean: 'encode'?
Exception in _motion_message_received when handling msg on 'frigate/g_camera/motion/state': 'ON' Traceback (most recent call last): File "/config/custom_components/frigate/camera.py", line 247, in _motion_message_received self._attr_motion_detection_enabled = msg.payload.decode("utf-8") == "ON" ^^^^^^^^^^^^^^^^^^ AttributeError: 'str' object has no attribute 'decode'. Did you mean: 'encode'?
Exception in _state_message_received when handling msg on 'frigate/g_camera/recordings/state': 'ON' Traceback (most recent call last): File "/config/custom_components/frigate/camera.py", line 241, in _state_message_received self._attr_is_recording = msg.payload.decode("utf-8") == "ON" ^^^^^^^^^^^^^^^^^^ AttributeError: 'str' object has no attribute 'decode'. Did you mean: 'encode'?

Describe the bug

Changing line 247 and 241 from decode to encode fixes the error but I have no idea if this is the right path

Debug log


Add your logs here.
aredon commented 2 months ago

The behavior of this seems to be that the switch for recordings (and motion?) provided by the integration always says "off" even if the recording state is actually "on" inside Frigate. The switch still works if you toggle it once for on and twice for off - but its state can no longer be relied upon.

changeofaspect commented 2 months ago

The behavior of this seems to be that the switch for recordings (and motion?) provided by the integration always says "off" even if the recording state is actually "on" inside Frigate. The switch still works if you toggle it once for on and twice for off - but its state can no longer be relied upon.

Just updated to Home Assistant 2024.5.0 and I now have this problem too. It affects the Recordings and Motion switches for all my cameras in the integration, regardless of the state inside Frigate. Switches can be toggled to on but after 30s turn off again. The Detection and Snapshots switches work as they should.

WilldabeastHA commented 2 months ago

I have the same issue as well. only with the recordings and motion switches/booleans in HA. I tried rolling back HA to 2024.4.0 but the problem persists with the opposite issue, the booleans will report and stay on regardless of what the status is in the frigate UI.

I do not get the same error when in the log when I enable debugging. I don't see any errors.

2024-05-02 13:35:41.035 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.564 seconds (success: True)
2024-05-02 13:35:45.473 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.002 seconds (success: True)
2024-05-02 13:35:51.018 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.547 seconds (success: True)
2024-05-02 13:35:55.473 DEBUG (MainThread) [custom_components.frigate] Finished fetching frigate data in 0.002 seconds (success: True)

I do see something in MQTT debug log that I'm not sure if it's related:

024-05-02 13:38:40.826 DEBUG (MainThread) [homeassistant.components.mqtt.client] xxx.xxx.x.xxx: register write 29
2024-05-02 13:38:40.826 DEBUG (MainThread) [homeassistant.components.mqtt.client] Transmitting message on frigate/Front-Door/motion/set: 'ON', mid: 124, qos: 0
2024-05-02 13:38:40.827 DEBUG (MainThread) [homeassistant.components.mqtt.client] xxx.xxx.x.xxx: unregister write 29
2024-05-02 13:38:40.828 DEBUG (MainThread) [homeassistant.components.mqtt.client] Received message on frigate/Front-Door/motion/state (qos=0): b'ON'
2024-05-02 13:38:41.200 DEBUG (MainThread) [homeassistant.components.mqtt.client] xxx.xxx.x.xxx: register write 29
2024-05-02 13:38:41.200 DEBUG (MainThread) [homeassistant.components.mqtt.client] Transmitting message on frigate/Front-Door/recordings/set: 'ON', mid: 125, qos: 0
2024-05-02 13:38:41.201 DEBUG (MainThread) [homeassistant.components.mqtt.client] xxx.xxx.x.xxx: unregister write 29
2024-05-02 13:38:41.201 DEBUG (MainThread) [homeassistant.components.mqtt.client] Received message on frigate/Front-Door/recordings/state (qos=0): b'ON'
2024-05-02 13:38:41.917 DEBUG (MainThread) [homeassistant.components.mqtt.client] xxx.xxx.x.xxx: register write 29
2024-05-02 13:38:41.917 DEBUG (MainThread) [homeassistant.components.mqtt.client] Transmitting message on frigate/garage/motion/set: 'ON', mid: 126, qos: 0
2024-05-02 13:38:41.918 DEBUG (MainThread) [homeassistant.components.mqtt.client] xxx.xxx.x.xxx: unregister write 29
2024-05-02 13:38:41.918 DEBUG (MainThread) [homeassistant.components.mqtt.client] Received message on frigate/garage/motion/state (qos=0): b'ON'
2024-05-02 13:38:42.234 DEBUG (MainThread) [homeassistant.components.mqtt.client] xxx.xxx.x.xxx: register write 29
2024-05-02 13:38:42.234 DEBUG (MainThread) [homeassistant.components.mqtt.client] Transmitting message on frigate/garage/recordings/set: 'ON', mid: 127, qos: 0
2024-05-02 13:38:42.235 DEBUG (MainThread) [homeassistant.components.mqtt.client] xxx.xxx.x.xxx: unregister write 29
2024-05-02 13:38:42.235 DEBUG (MainThread) [homeassistant.components.mqtt.client] Received message on frigate/garage/recordings/state (qos=0): b'ON'
2024-05-02 13:38:43.151 DEBUG (MainThread) [homeassistant.components.mqtt.client] xxx.xxx.x.xxx: register write 29
2024-05-02 13:38:43.151 DEBUG (MainThread) [homeassistant.components.mqtt.client] Transmitting message on frigate/garage2/motion/set: 'ON', mid: 128, qos: 0
2024-05-02 13:38:43.151 DEBUG (MainThread) [homeassistant.components.mqtt.client] xxx.xxx.x.xxx: unregister write 29
2024-05-02 13:38:43.152 DEBUG (MainThread) [homeassistant.components.mqtt.client] Received message on frigate/garage2/motion/state (qos=0): b'ON'
2024-05-02 13:38:43.518 DEBUG (MainThread) [homeassistant.components.mqtt.client] xxx.xxx.x.xxx: register write 29
2024-05-02 13:38:43.518 DEBUG (MainThread) [homeassistant.components.mqtt.client] Transmitting message on frigate/garage/snapshots/set: 'ON', mid: 129, qos: 0
2024-05-02 13:38:43.519 DEBUG (MainThread) [homeassistant.components.mqtt.client] xxx.xxx.x.xxx: unregister write 29
aredon commented 2 months ago

YMMV on this but I rolled back to 2024.4.4 without any issues. Everything is back to working as expected.

WilldabeastHA commented 2 months ago

YMMV on this but I rolled back to 2024.4.4 without any issues. Everything is back to working as expected.

I can confirm this does allow the switches/booleans to operate as intended.

Is this a HA issue or a frigate integration issue?

WilldabeastHA commented 2 months ago

I think my file is different than yours.

Screenshot_20240502_163354

xakepShilo commented 2 months ago

I think my file is different than yours.

Sorry, it was a mistake!

pdobrien3 commented 2 months ago

@WilldabeastHA, what file is mentioned in the error message? The error message i got when turning on debug: true provided everything i needed to fix the file locally. I am also running the frigate integration with a manual install under config/custom_componenets though.

also, it is not turning on debug mode for the integration. 2024.5 added an additional debug option at the core level

homeassistant:
  debug: true

my instance is working as expected with the changes mentioned in my error message

changeofaspect commented 2 months ago

my instance is working as expected with the changes mentioned in my error message

I was not getting any error messages, just that the Recordings and Motion switches show off. I can see MQTT messages and see set ON or set OFF transissions and can see the State ON or State OFF replies. I thought I would try your suggestion so in camera.py, I changed decode to encode in lines 241 & 247. It didn't appear to make any difference but I now got an error message logged:-

Logger: homeassistant.util.logging
Source: util/logging.py:98
First occurred: 13:34:53 (14 occurrences)
Last logged: 13:35:43

Exception in _state_message_received when handling msg on 'frigate/camera_name_1/recordings/state': 'b'ON'' Traceback (most recent call last): File "/config/custom_components/frigate/camera.py", line 241, in _state_message_received self._attr_is_recording = msg.payload.encode("utf-8") == "ON" ^^^^^^^^^^^^^^^^^^ AttributeError: 'bytes' object has no attribute 'encode'. Did you mean: 'decode'?
Exception in _motion_message_received when handling msg on 'frigate/camera_name_1/motion/state': 'b'ON'' Traceback (most recent call last): File "/config/custom_components/frigate/camera.py", line 247, in _motion_message_received self._attr_motion_detection_enabled = msg.payload.encode("utf-8") == "ON" ^^^^^^^^^^^^^^^^^^ AttributeError: 'bytes' object has no attribute 'encode'. Did you mean: 'decode'?
Exception in _state_message_received when handling msg on 'frigate/camera_name_2/recordings/state': 'b'ON'' Traceback (most recent call last): File "/config/custom_components/frigate/camera.py", line 241, in _state_message_received self._attr_is_recording = msg.payload.encode("utf-8") == "ON" ^^^^^^^^^^^^^^^^^^ AttributeError: 'bytes' object has no attribute 'encode'. Did you mean: 'decode'?
Exception in _motion_message_received when handling msg on 'frigate/camera_name_2/motion/state': 'b'ON'' Traceback (most recent call last): File "/config/custom_components/frigate/camera.py", line 247, in _motion_message_received self._attr_motion_detection_enabled = msg.payload.encode("utf-8") == "ON" ^^^^^^^^^^^^^^^^^^ AttributeError: 'bytes' object has no attribute 'encode'. Did you mean: 'decode'?

AttributeError: 'bytes' object has no attribute 'encode'. Did you mean: 'decode'? !!!!!!!

I have changed it back to decode and the error message has cleared.

WilldabeastHA commented 2 months ago

@pdobrien3 what changes did you make?

When I enable debugging for HA, it doesn't show any errors. If I enable debugging for Frigate and MQTT integration, what I posted above is what I see that seems suspicious. Not sure what I need to change to make it all work correctly.

pdobrien3 commented 2 months ago

this is my working code:

    @callback  # type: ignore[misc]
    def _state_message_received(self, msg: ReceiveMessage) -> None:
        """Handle a new received MQTT state message."""
        self._attr_is_recording = msg.payload.encode("utf-8") == "ON"
        self.async_write_ha_state()

    @callback  # type: ignore[misc]
    def _motion_message_received(self, msg: ReceiveMessage) -> None:
        """Handle a new received MQTT extra message."""
        self._attr_motion_detection_enabled = msg.payload.encode("utf-8") == "ON"
        self.async_write_ha_state()

I would assume you need to be on 2024.5

changeofaspect commented 2 months ago

this is my working code:

    @callback  # type: ignore[misc]
    def _state_message_received(self, msg: ReceiveMessage) -> None:
        """Handle a new received MQTT state message."""
        self._attr_is_recording = msg.payload.encode("utf-8") == "ON"
        self.async_write_ha_state()

    @callback  # type: ignore[misc]
    def _motion_message_received(self, msg: ReceiveMessage) -> None:
        """Handle a new received MQTT extra message."""
        self._attr_motion_detection_enabled = msg.payload.encode("utf-8") == "ON"
        self.async_write_ha_state()

I would assume you need to be on 2024.5

Yes, I am on 2024.5 and I tried your code (encode instead of decode). It did not fix the problem, the Recording and Motion switches remain OFF but it did create logged errors ........... AttributeError: 'bytes' object has no attribute 'encode'. Did you mean: 'decode'?

Your set up must be different to mine in some way. Thinking about it, this relates to received messages which should already be encoded in UTF-8 so surely, it should be decode and not encode ?

pdobrien3 commented 2 months ago

I am in no way smart when it comes to coding. I enabled debug: true in beta, restarted, and got the error message. i made changes according to the error message and the error message went away. i am not even sure my motion/recording switches were broken to begin with, I do not use HACS, i install all my custom components manually. This is likely where our installs differ but i do not know. hopefully someone responsible for the integration will chime in soon

changeofaspect commented 2 months ago

@pdobrien3 I am definitely in the novice category when it comes to coding. I installed my set up via HACS instead of manually but I am not sure why that would make a difference.

NickM-27 commented 2 months ago

It definitely shouldn't be encode. It's not clear to me if this issue is always happening or only when debug is enabled

pdobrien3 commented 2 months ago

I can revert my changes and turn off debug and see what happens.

NickM-27 commented 2 months ago

Things are working as expected for me with the latest home assistant version, not sure why only some are seeing issues

pdobrien3 commented 2 months ago

so checking again before reverting.

changing line 247 and 241 from decode to encode with debug: true set, i was able to change all the switches (motion, detect, snapshot, and recording) on and off from both home assistant and frigate and see a correct reaction on the opposite platform without any errors in home assistant

changing line 247 and 241 back to decode and hashing out debug: true, I got the error at startup as well as when switches are changed:

Logger: homeassistant.util.logging
Source: util/logging.py:98
First occurred: 8:17:50 AM (16 occurrences)
Last logged: 8:21:11 AM

Exception in _state_message_received when handling msg on 'frigate/one_camera/recordings/state': 'ON' Traceback (most recent call last): File "/config/custom_components/frigate/camera.py", line 241, in _state_message_received self._attr_is_recording = msg.payload.decode("utf-8") == "ON" ^^^^^^^^^^^^^^^^^^ AttributeError: 'str' object has no attribute 'decode'. Did you mean: 'encode'?
Exception in _state_message_received when handling msg on 'frigate/two_camera/recordings/state': 'OFF' Traceback (most recent call last): File "/config/custom_components/frigate/camera.py", line 241, in _state_message_received self._attr_is_recording = msg.payload.decode("utf-8") == "ON" ^^^^^^^^^^^^^^^^^^ AttributeError: 'str' object has no attribute 'decode'. Did you mean: 'encode'?
Exception in _motion_message_received when handling msg on 'frigate/two_camera/motion/state': 'OFF' Traceback (most recent call last): File "/config/custom_components/frigate/camera.py", line 247, in _motion_message_received self._attr_motion_detection_enabled = msg.payload.decode("utf-8") == "ON" ^^^^^^^^^^^^^^^^^^ AttributeError: 'str' object has no attribute 'decode'. Did you mean: 'encode'?
Exception in _motion_message_received when handling msg on 'frigate/two_camera/motion/state': 'ON' Traceback (most recent call last): File "/config/custom_components/frigate/camera.py", line 247, in _motion_message_received self._attr_motion_detection_enabled = msg.payload.decode("utf-8") == "ON" ^^^^^^^^^^^^^^^^^^ AttributeError: 'str' object has no attribute 'decode'. Did you mean: 'encode'?
Exception in _state_message_received when handling msg on 'frigate/two_camera/recordings/state': 'ON' Traceback (most recent call last): File "/config/custom_components/frigate/camera.py", line 241, in _state_message_received self._attr_is_recording = msg.payload.decode("utf-8") == "ON" ^^^^^^^^^^^^^^^^^^ AttributeError: 'str' object has no attribute 'decode'. Did you mean: 'encode'?

I was able to change all the switches (motion, detect, snapshot, and recording) on and off from both home assistant and frigate and see a correct reaction on the opposite platform but motion and recording generated errors.

easyservices commented 2 months ago

I am on HA Core (linux amd64) on version 2024.5.1 with Frigate V5.1.0 and Frigate Server 0.13.2 and I also have the same error message (please see below), whatever debug mode is activated or not.

If I create new additional MQTT switches for controlling the recordings and snapshots, everything is fine and even the switches created by the frigate add-on work as well (even if from times to times the error log happens again) but at least all switches (new manually added ones and the ones from frigate addons will work).

If I remove my manually added MQTT switches then the ones from frigate won't work anymore.

Here is the error message that pops up : Exception in _state_message_received when handling msg on 'frigate/cam_garage/recordings/state': 'ON' Traceback (most recent call last): File "/config/custom_components/frigate/camera.py", line 241, in _state_message_received self._attr_is_recording = msg.payload.decode("utf-8") == "ON" ^^^^^^^^^^^^^^^^^^ AttributeError: 'str' object has no attribute 'decode'. Did you mean: 'encode'?

easyservices commented 2 months ago

btw I also get now the following error msg : Error fetching information from http://xxxxx:5000/api/stats: Cannot connect to host xxxxx:5000 ssl:default [Connect call failed ('xxxx', 5000)]

I did not have at all the issue with the previous HA version. It seems it tries to connect using SSL on a non SSL port.

changeofaspect commented 2 months ago

I am on HA Core (generic x86-64) on version 2024.5.1, Supervisor 2024.04.4, OS 12.2 with Frigate Integration V5.1.0 and Frigate Server 0.13.2. I don't get any error messages unless I change lines 241 and 247 in camera.py to encode instead of decode. I have returned them to decode which is what they originally were.

I used developer tools > services to publish MQTT messages with topic frigate/camera_name/recordings/set with payload of ON or OFF and Frigate responds. I can do the same with detect, motion and snapshots. Frigate always responds.

I can listen to MQTT topic frigate/camera_name/recordings/state and always get a message with payload either ON or OFF immediately after calling the service. This also works for detect, motion and snapshots.

So I took it one stage further and set up a test automation that is triggered by frigate/camera_name/recordings/state with payload of ON (and a second trigger with payload of OFF). The action is to turn on or off an input_boolean for testing.

It works for detect and snapshots but does NOT work for motion or recordings. The payload in the motion and recordings state does not trigger the Automation even though the MQTT listener shows it as ON or OFF, exactly the same as in detect and snapshots. If it can't trigger the Automation, may be the problem lies somewhere else and not within the Frigate Integration ??

aredon commented 2 months ago

Things are working as expected for me with the latest home assistant version, not sure why only some are seeing issues

You will need to be more specific as 2024.5.1 is released now. Are you on 5.0 or 5.1?

dermotduffy commented 2 months ago

I suspect there might be multiple unrelated reports mixed here. I cannot get any exceptions thrown no matter what I do, with or without debug: true.

However, I can definitely see the switch state behavior problem with recordings and motion only. In this image, I turn all 4 entities on and 2 of them immediately reset:

problem

Versions:

dermotduffy commented 2 months ago

MQTT contents of a recordings topic:

$ mosquitto_sub -h localhost -t 'frigate/kitchen/recordings/state'
ON <-- Initial value

OFF <- I toggle off in Frigate UI
ON <- I toggle on in Frigate UI

ON <- I toggle on in HA UI
<- Nothing new on MQTT topic, yet HA switches it off
richardfoley commented 2 months ago

This sounds like the same issue I have since I upgraded to 2024.5.0, (for reference only, reported here).

dermotduffy commented 2 months ago

Some progress: The recordings state data is being received as b'ON' not ON, yet the comparison to determine the state in the integration is just against ON If we decode the string first, the recordings switch starts to work correctly. There's a similar issue in reverse in camera.py which explains the exceptions shown at the start of this issue.

I think motion might be a subtly different problem / race condition, still looking...

frank2604 commented 2 months ago

I suspect there might be multiple unrelated reports mixed here. I cannot get any exceptions thrown no matter what I do, with or without debug: true.

However, I can definitely see the switch state behavior problem with recordings and motion only. In this image, I turn all 4 entities on and 2 of them immediately reset:

problem

Versions:

  • Integration/Frigate: 5.1.0/0.13.2-6476f8a
  • HA: 2024.5.1

Same here with same Versions of Frigate and HAOS

dermotduffy commented 2 months ago

The motion problem is different. Taking HA entirely out of the picture, looking just at the MQTT messages. Here is recordings, top console is publishing a message, bottom is subscribing. Every published message sets the state correctly, and it's echo'd back in the state topic:

recordings

Here is motion topic, only ON is republished back ...

motion

@NickM-27 Is there something fundamentally different about how these topics are intended to behave on the backend?

dermotduffy commented 2 months ago

Checking the backend code, I think this is probably intentional:

    def _on_motion_command(self, camera_name: str, payload: str) -> None:
        """Callback for motion topic."""
        detect_settings = self.config.cameras[camera_name].detect
        motion_settings = self.config.cameras[camera_name].motion

        if payload == "ON":
            if not motion_settings.enabled:
                logger.info(f"Turning on motion for {camera_name}")
                motion_settings.enabled = True
        elif payload == "OFF":
            if detect_settings.enabled:
                logger.error(
                    "Turning off motion is not allowed when detection is enabled."
                )
                return   <--------------------------------- HERE

            if motion_settings.enabled:
                logger.info(f"Turning off motion for {camera_name}")
                motion_settings.enabled = False

        self.config_updater.publish(f"config/motion/{camera_name}", motion_settings)
        self.publish(f"{camera_name}/motion/state", payload, retain=True)

i.e. Frigate will not allow motion to be disabled, when detection is turned on. If I turn detection off, it behaves correctly. So I think this is all WAI, and the user simply needs to accept that they cannot turn off motion but keep detection on.

As such, the draft PR probably resolves this issue as much as it will be resolved.

dermotduffy commented 2 months ago

The fix PR is merged. I'll do a v5.2.0 release tomorrow.

aredon commented 2 months ago

Checking the backend code, I think this is probably intentional:

    def _on_motion_command(self, camera_name: str, payload: str) -> None:
        """Callback for motion topic."""
        detect_settings = self.config.cameras[camera_name].detect
        motion_settings = self.config.cameras[camera_name].motion

        if payload == "ON":
            if not motion_settings.enabled:
                logger.info(f"Turning on motion for {camera_name}")
                motion_settings.enabled = True
        elif payload == "OFF":
            if detect_settings.enabled:
                logger.error(
                    "Turning off motion is not allowed when detection is enabled."
                )
                return   <--------------------------------- HERE

            if motion_settings.enabled:
                logger.info(f"Turning off motion for {camera_name}")
                motion_settings.enabled = False

        self.config_updater.publish(f"config/motion/{camera_name}", motion_settings)
        self.publish(f"{camera_name}/motion/state", payload, retain=True)

i.e. Frigate will not allow motion to be disabled, when detection is turned on. If I turn detection off, it behaves correctly. So I think this is all WAI, and the user simply needs to accept that they cannot turn off motion but keep detection on.

As such, the draft PR probably resolves this issue as much as it will be resolved.

Isn't this backwards? The motion switch is erroneously toggling off even when on. This "prevention" you're describing seems like it would only force the switch to stay on?

pdobrien3 commented 2 months ago

i.e. Frigate will not allow motion to be disabled, when detection is turned on. If I turn detection off, it behaves correctly. So I think this is all WAI, and the user simply needs to accept that they cannot turn off motion but keep detection on.

This has always been the case and it should stay that way imho.

dermotduffy commented 2 months ago

Isn't this backwards? The motion switch is erroneously toggling off even when on. This "prevention" you're describing seems like it would only force the switch to stay on?

That's right. It cannot be turned off, when detection is turned on. You can try to turn it off in HA, but it will reset to on as the backend is rejecting the request.

dermotduffy commented 2 months ago

New release: https://github.com/blakeblackshear/frigate-hass-integration/releases/tag/v5.2.0

aredon commented 2 months ago

Isn't this backwards? The motion switch is erroneously toggling off even when on. This "prevention" you're describing seems like it would only force the switch to stay on?

That's right. It cannot be turned off, when detection is turned on. You can try to turn it off in HA, but it will reset to on as the backend is rejecting the request.

Right but the issue at hand is that the switch provided by the integration is toggling itself off - which obviously can't happen while detection is active. The correct behavior seems like it should be that the switch toggles itself on while detection is active. So I don't understand how this is WAI or solved. Current switch behavior seems like it is exactly backwards of what would be expected.

Maybe I'm misunderstanding.

dermotduffy commented 2 months ago

Right but the issue at hand is that the switch provided by the integration is toggling itself off

Prior to the "fix", the backend would report 'ON' but the integration would interpret it as 'OFF'. That causes the HA state to appear to be out of sync. Here's how it looks now:

Peek 2024-05-05 10-20

It's a little hard to see without the mouse cursor, but:

changeofaspect commented 2 months ago

New release: https://github.com/blakeblackshear/frigate-hass-integration/releases/tag/v5.2.0

Just installed v5.2.0 and I can confirm that all the switches are now working correctly. Many thanks for fixing this, much appreciated.

pdobrien3 commented 2 months ago

yes, thank you. looks like it is working for me also

dermotduffy commented 2 months ago

Thanks for the confirmation!

richardfoley commented 2 months ago

Confirming 5.2.0 working as expected, and many thanks for the prompt fix. (thumbs-up + party emoticons)

WilldabeastHA commented 2 months ago

Right but the issue at hand is that the switch provided by the integration is toggling itself off

Prior to the "fix", the backend would report 'ON' but the integration would interpret it as 'OFF'. That causes the HA state to appear to be out of sync. Here's how it looks now:

Peek 2024-05-05 10-20 Peek 2024-05-05 10-20

It's a little hard to see without the mouse cursor, but:

  • When detect is manually turned on, you'll notice motion turns on too.
  • When motion is manually turned off, but detect is on, motion will reset itself to on.
  • When detect is manually turned off, then motion can be turned off.

I have the same issue with the "Motion" boolean. I can confirm the other booleans (Detect, Recordings, Snapshot) work correct after the v5.2 update .

Thank you for your support and attention to this. Much appreciated!