tsightler / ring-mqtt

Ring devices to MQTT Bridge
MIT License
600 stars 106 forks source link

Disarming not working when requested by a scene #935

Closed KC-inDomus closed 4 days ago

KC-inDomus commented 5 days ago

Is there an existing issue for this?

Is this really a bug or just a usage/support question?

Have you read and followed any recommendations in the Support and Troubleshooting section of the wiki?

Did this issue start after an upgrade?

Are you prepared to respond and provide all relevant information (logs, screenshots, etc)

Describe the Bug

Disarming not working when requested by a scene

Steps to Reproduce

Call disarm from Scene

Expected Behavior

Should disable

Log Output

WARNING (MainThread) [homeassistant.components.mqtt.alarm_control_panel] Wrong code entered for disarming

Screenshots

No response

Config File

scene:
- name: test
  entities:
    alarm_control_panel.alarm_name:
      state: disarmed
      code: 0123

Calling scene.turn_on for scene.test entity gives "wrong code".
Calling alarm_control_panel.alarm_disarm from action panel on webgui, this works:

action: alarm_control_panel.alarm_disarm
data:
  entity_id: alarm_control_panel.alarm_name
  code: 0123

Install Type

Home Assistant Core@Docker

Version

2024.11.2

Operating System

Linux Debian

Architecture

x86_64

Machine Details

Mini PC

tsightler commented 4 days ago

Closing this as I don't see any way possible this is an addon bug. Feels like it has to be a HA bug and I saw that you already opened an issue there. If, for some reason, you have some proof that this is caused by the addon and not HA, feel free to reopen.

tsightler commented 4 days ago

Actually, I'm going to reopen and ask a few questions. Do you have a code set in the ring-mqtt configuration?

KC-inDomus commented 4 days ago

Actually, I'm going to reopen and ask a few questions. Do you have a code set in the ring-mqtt configuration?

the only code I had set is ring-app side.

tsightler commented 4 days ago

Then why are you including a code in the automation? If you have no code configured in ring-mqtt then you don't need a code for the automations at all. What happens if you just remove the code from the scene automation?

KC-inDomus commented 4 days ago

Then why are you including a code in the automation? If you have no code configured in ring-mqtt then you don't need a code for the automations at all. What happens if you just remove the code from the scene automation?

just made a try. code is needed to arm and disarm, using action panel. for example this don't work:

action: alarm_control_panel.alarm_disarm
data:
  entity_id: alarm_control_panel.alarm_name

instead, this work:

action: alarm_control_panel.alarm_disarm
data:
  entity_id: alarm_control_panel.alarm_name
  code: 0123

so, code seems to be needed.

tsightler commented 4 days ago

I don't know why it would be required in any case, all current versions of ring-mqtt set code_disarm_required: false if no code is set in the addon configuration. This feels like yet another HA bug in how they handle codes.

KC-inDomus commented 4 days ago

I don't know why it would be required in any case, all current versions of ring-mqtt set code_disarm_required: false if no code is set in the addon configuration. This feels like yet another HA bug in how they handle codes.

code_disarm_required: false ins't a bit insicure, above all?

tsightler commented 4 days ago

code_disarm_required: false ins't a bit insicure, above all?

You said you didn't set a code in the addon config, so there is no code required for disarming, thus code_disarm_required: false is the only valid and correct setting. The Ring app also doesn't require a code to disarm, is it insecure? It assumes you are protected by your device authentication. By default, the addon assumes you HA is secured from non-authenticated access as well, so no different.

If you want to use a code with ring-mqtt, you must set a code in the addon config and then it will set code_disarm_required: true which enforces use of a code in HA.

KC-inDomus commented 4 days ago

I apologise. was sure hadn't a code in my ring-mqtt config, but I had (btw, the code was right). Now I removed that entry, and now it's working fine both on action calling and scene calling. the entire round is not clear to me btw, I'll go more in detail.

tsightler commented 4 days ago

OK, well, that re-enforces that this problem is 100% in HA, so I'm going to revert this back to closed. Thanks for your quick responses, hopefully the HA team can address the issue.

tsightler commented 4 days ago

Took a quick look at the scene code in HA and I don't believe that it supports code option as it appears to be only a very basic proxy for state and there's no device/entity specific logic that I could see, so I believe it is just ignoring the code completely, thus why the service returns the error. I think this boils down to a feature requests for HA if anything at all.

However, as an alternative, you can fairly easily link an automation to a scene change. It's not possible to directly trigger an automation from a scene, however, any time an scene is activated it creates an event, and you can trigger on an event, so, based on your scene example above you can create an automation like this:

- alias: 'On test Activated'
  trigger:
    platform: event
    event_type: 'call_service'
    event_data:
      domain: scene
      service: turn_on
      service_data:
        entity_id: scene.test
  action:
actions:
  - action: alarm_control_panel.alarm_disarm
    data:
      entity_id: alarm_control_panel.alarm_name
      code: 0123