nielsfaber / alarmo

Easy to use alarm system integration for Home Assistant
1.24k stars 117 forks source link

Alarmo With google #967

Open awptechnologies opened 3 weeks ago

awptechnologies commented 3 weeks ago

Alarmo Version

v1.10.2

HA Version

2024.7.0

Bug description

After latest update of alarmo i can now arm and disarm with google. The only issue is google still says sorry i was unable to connect. Again it does actually work but for some reason google thinks it doesnt. I can deal with it just a bummer because it makes me feel like i need to check weather it worked or not everytime.

Steps to reproduce

ask google to arm or disarm security system

Relevant log output

No response

awptechnologies commented 3 weeks ago

if this is only me i will deal with it. Thank you for an amazing do it yourself alarm system. by far the best.

Baldhor commented 3 weeks ago

if this is only me i will deal with it. Thank you for an amazing do it yourself alarm system. by far the best.

Hello, I confirm you are not the only one. Arming (no pin code) give me an error, but the alarm is still arming correctly, II'm using the following automation to compensate:

alias: Notif Armement Commence
description: ""
trigger:
  - platform: device
    device_id: 2692eb9f260d44f098dfce36e4928be0
    domain: alarm_control_panel
    entity_id: ff19188a9f26db85e7481704af831039
    type: arming
condition: []
action:
  - service: script.envoyer_message_vocal_sur_hub
    metadata: {}
    data:
      notif: L'alarme est armée, vous avez 30 secondes pour sortir
mode: single

As for disarm (with pin code), I use the following automation:

alias: Notif Alarme Désactivée
description: ""
trigger:
  - platform: state
    entity_id:
      - alarm_control_panel.alarmo
    to: disarmed
condition: []
action:
  - service: script.envoyer_message_vocal_sur_hub
    metadata: {}
    data:
      notif: L'alarme est désactivée
mode: single

Yes, it's in French, I'm using my own google assistant integration to support French. The standard integration of Google Assistant is hard coded in English ... : https://github.com/Baldhor/baldhor-google-assistant

nielsfaber commented 3 weeks ago

I am using google home to control alarmo as well, I am having the same issue. In addition, when arming with an exit delay google always says "something went wrong controlling [name of alarm]". I believe the issue is not caused by alarmo but by the HA - google integration. If you want to further investigate if this is true, you could try out the manual alarm integration. If this integration can be controlled without any issues via google home, the problem is possibly caused by alarmo. If this integration has the same problem, the problem is caused by HA.

Baldhor commented 3 weeks ago

I also believe it is caused by the google home integration, I will try to investigate it using my "french" version :) Feel free to either assign this issue to me or put it in stage

edit : I forgot to write it in my previous comment :)

Baldhor commented 2 weeks ago

Hello, I made some tests and I can confirm the problem come the google assistant integration. Actually, it's just a little more complicated, google assistant doesn't support as far as I can tell "arming delay".

Asking from google to arm will result in this answer from the google assistant integration :

{'commands': [{'ids': ['alarm_control_panel.alarmo'],
'states': {'isArmed': False, 'online': True},
'status': 'SUCCESS'}]}

isArmed being false will trigger the "error message" from google assistant. If I hack the code and force the value 'True', the voice will tell a success which is great. But Google assistant will think that the alarm is armed (not just arming).

I think this defect is acceptable, so I'm planning to find a "not too ugly" way to do it in my french fork. However, I'm not capable to propose a fix to home assistant github, sorry :)

Baldhor commented 2 weeks ago

@nielsfaber

Refer to previous comment as a baseline.

Actually, the google home integration already support it natively:

    def query_attributes(self):
        """Return ArmDisarm query attributes."""
        armed_state = self.state.attributes.get("next_state", self.state.state)

The alarm entity in home assistant must have a "next_state" attribute that match the arm level after the arming delay. In Alarmo alarm_control_panel, it match with the property 'arm_mode'.

I added this property:

    @property
    def next_state(self):
        """Return the arm mode."""
        _LOGGER.debug("next_state called and return {}".format(self.arm_mode))
        return self.arm_mode

And so added it as an extra state attribute:

    @property
    def extra_state_attributes(self):
        """Return the data of the entity."""

        return {
            "arm_mode": self.arm_mode,
            "next_state": self.next_state,
            "open_sensors": self.open_sensors,
            "bypassed_sensors": self.bypassed_sensors,
            "delay": self.delay,
        }

Magic, it works as expected: 1/ If a window is open when I arm, it will tell the error 2/ If everything is fine when I arm (with or without delay), it will not tell the error

Would you push that little enhancement into your next version? I understand you use google assistant too, so you should be able to test it out :)

nielsfaber commented 2 weeks ago

@Baldhor Great find! I had no idea this attribute was expected, don't think it is anywhere documented. I will definitely add this in the next update.

@awptechnologies I'm not sure if this improvement will solve the issue you're experiencing.

Baldhor commented 2 weeks ago

@Baldhor Great find! I had no idea this attribute was expected, don't think it is anywhere documented. I will definitely add this in the next update.

@awptechnologies I'm not sure if this improvement will solve the issue you're experiencing.

Yes, I miss read the issue of awp at start "was unable to connect" ... Actually, it's this part my enhancement fix:

In addition, when arming with an exit delay google always says "something went wrong controlling [name of alarm]".

Who know, maybe it will fix both, we will see ... Otherwise, please activate the log of the google assistant, and provide it, I may be able to analyze it.

Baldhor commented 2 weeks ago

@nielsfaber Just noticed, it still tell an error when disarming:

2024-06-16 12:13:10.176 DEBUG (MainThread) [custom_components.baldhor_google_assistant.smart_home] Processing message:
{'inputs': [{'context': {'locale_country': 'FR', 'locale_language': 'fr'},
'intent': 'action.devices.EXECUTE',
'payload': {'commands': [{'devices': [{'id': 'alarm_control_panel.alarmo'}],
'execution': [{'challenge': {'pin': 'hidden'},
'command': 'action.devices.commands.ArmDisarm',
'params': {'arm': False}}]}]}}],
'requestId': '9623913327917478774'}
2024-06-16 12:13:10.179 DEBUG (MainThread) [custom_components.baldhor_google_assistant.smart_home] Response:
{'commands': [{'ids': ['alarm_control_panel.alarmo'],
'states': {'currentArmLevel': 'armed_night',
'isArmed': True,
'online': True},
'status': 'SUCCESS'}]}
2024-06-16 12:13:10.183 DEBUG (SyncWorker_5) [custom_components.alarmo.alarm_control_panel] alarm_disarm
2024-06-16 12:13:10.629 DEBUG (SyncWorker_5) [custom_components.alarmo.alarm_control_panel] entity alarm_control_panel.alarmo was updated from armed_night to disarmed
2024-06-16 12:13:10.630 DEBUG (MainThread) [custom_components.alarmo.automations] state of alarm_control_panel.alarmo is updated from armed_night to disarmed
2024-06-16 12:13:10.630 DEBUG (MainThread) [custom_components.alarmo.automations] Executing automation 1717245148
2024-06-16 12:13:10.635 DEBUG (SyncWorker_1) [custom_components.alarmo.alarm_control_panel] ready_to_arm_modes for Alarmo updated to
2024-06-16 12:13:10.638 INFO (SyncWorker_5) [custom_components.alarmo.alarm_control_panel] Alarm 'Alarmo' is disarmed by Baldhor.
2024-06-16 12:13:10.641 DEBUG (MainThread) [custom_components.alarmo.alarm_control_panel] next_state called and return None
2024-06-16 12:13:10.660 DEBUG (MainThread) [custom_components.baldhor_google_assistant.report_state] Scheduling report state for alarm_control_panel.alarmo: {'online': True, 'isArmed': False}

The alarm_disarm function has asynchronous processing (almost 500ms), it must be synchronous :( No idea what should be changed without side effect.

mattfox27 commented 1 week ago

Same issue, shows offline in Google home unless system is armed

Baldhor commented 1 week ago

Same issue, shows offline in Google home unless system is armed

Need logs, I do not have this issue.

mattfox27 commented 1 week ago

Same issue, shows offline in Google home unless system is armed

Need logs, I do not have this issue.

Which logs? From google home?

Baldhor commented 1 week ago

Yes

Le jeu. 20 juin 2024, 19:29, Matt Klimmer @.***> a écrit :

Same issue, shows offline in Google home unless system is armed

Need logs, I do not have this issue.

Which logs? From google home?

— Reply to this email directly, view it on GitHub https://github.com/nielsfaber/alarmo/issues/967#issuecomment-2181193967, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANXYPVONQ2AUPS4CMW6IUCDZIMGOJAVCNFSM6AAAAABI72KDLGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOBRGE4TGOJWG4 . You are receiving this because you were mentioned.Message ID: @.***>

awptechnologies commented 1 week ago

how do we pull logs from google home?

Pixel-Gavin commented 1 week ago

I've got the identical issue, appears offline if unarmed and gives me an error when trying to disarm.

mattfox27 commented 1 week ago

I've got the identical issue, appears offline if unarmed and gives me an error when trying to disarm.

so what I did was arm it using my voice in google home, "hey google set alarm to armed home" and it seems like it kind of fixed it, I still cant disarm via voice even when I set a pin but it seemed like it at least stopped showing offline when disarmed. Not sure if it persisted though I have not checked today.

mattfox27 commented 1 week ago

how do we pull logs from google home?

Ya I cannot figure out this also

Baldhor commented 1 week ago

@mattfox27 @awptechnologies

You need to activate the logs of the Google Home integration. image

Then in system -> parameters -> logs, you can load the "full logs".

awptechnologies commented 6 days ago

2024-06-25 21:13:42.940 DEBUG (MainThread) [homeassistant.components.google_assistant.smart_home] Processing message: {'inputs': [{'context': {'locale_country': 'US', 'locale_language': 'en'}, 'intent': 'action.devices.EXECUTE', 'payload': {'commands': [{'devices': [{'id': 'alarm_control_panel.home'}], 'execution': [{'command': 'action.devices.commands.ArmDisarm', 'params': {'arm': True, 'armLevel': 'armed_home'}}]}]}}], 'requestId': '15129948241725610372'} 2024-06-25 21:13:42.954 DEBUG (MainThread) [homeassistant.components.google_assistant.smart_home] Response: {'commands': [{'ids': ['alarm_control_panel.home'], 'states': {'currentArmLevel': 'armed_home', 'isArmed': False, 'online': True}, 'status': 'SUCCESS'}]} 2024-06-25 21:13:51.495 DEBUG (MainThread) [homeassistant.components.google_assistant.report_state] Scheduling report state for sensor.server_sensors_front_server: {'online': True, 'temperatureSetpointCelsius': 31.9, 'temperatureAmbientCelsius': 31.9} 2024-06-25 21:13:52.732 DEBUG (MainThread) [homeassistant.components.google_assistant.http] Response on https://homegraph.googleapis.com/v1/devices:reportStateAndNotification with data {'requestId': 'ea82ec91683545a9a0329ce6f11bb6ea', 'agentUserId': 'a9286e6a47ef40e4a8b9845de088fc24', 'payload': {'devices': {'states': {'sensor.server_sensors_front_server': {'online': True, 'temperatureSetpointCelsius': 31.9, 'temperatureAmbientCelsius': 31.9}}}}} was { "requestId": "ea82ec91683545a9a0329ce6f11bb6ea" }

2024-06-25 21:13:52.945 DEBUG (MainThread) [homeassistant.components.google_assistant.report_state] Scheduling report state for alarm_control_panel.home: {'online': True, 'isArmed': True, 'currentArmLevel': 'armed_home'} 2024-06-25 21:13:54.046 DEBUG (MainThread) [homeassistant.components.google_assistant.http] Response on https://homegraph.googleapis.com/v1/devices:reportStateAndNotification with data {'requestId': '0cbf8a0ad26b47a79eecafa57e0d8e1e', 'agentUserId': 'a9286e6a47ef40e4a8b9845de088fc24', 'payload': {'devices': {'states': {'alarm_control_panel.home': {'online': True, 'isArmed': True, 'currentArmLevel': 'armed_home'}}}}} was { "requestId": "0cbf8a0ad26b47a79eecafa57e0d8e1e" }

2024-06-25 21:13:58.120 DEBUG (MainThread) [homeassistant.components.google_assistant.smart_home] Processing message: {'inputs': [{'context': {'locale_country': 'US', 'locale_language': 'en'}, 'intent': 'action.devices.EXECUTE', 'payload': {'commands': [{'devices': [{'id': 'alarm_control_panel.home'}], 'execution': [{'command': 'action.devices.commands.ArmDisarm', 'params': {'arm': False}}]}]}}], 'requestId': '39298766513567840'} 2024-06-25 21:13:58.122 DEBUG (MainThread) [homeassistant.components.google_assistant.smart_home] Response: {'commands': [{'challengeNeeded': {'type': 'pinNeeded'}, 'errorCode': 'challengeNeeded', 'ids': ['alarm_control_panel.home'], 'status': 'ERROR'}]} 2024-06-25 21:14:00.039 DEBUG (MainThread) [homeassistant.components.google_assistant.report_state] Scheduling report state for sensor.master_sensors_a_c_out: {'online': True, 'temperatureSetpointCelsius': 15.2, 'temperatureAmbientCelsius': 15.2} 2024-06-25 21:14:01.146 DEBUG (MainThread) [homeassistant.components.google_assistant.http] Response on https://homegraph.googleapis.com/v1/devices:reportStateAndNotification with data {'requestId': '9ab81e1414db4a42ad62f07d1c7a7624', 'agentUserId': 'a9286e6a47ef40e4a8b9845de088fc24', 'payload': {'devices': {'states': {'sensor.master_sensors_a_c_out': {'online': True, 'temperatureSetpointCelsius': 15.2, 'temperatureAmbientCelsius': 15.2}}}}} was { "requestId": "9ab81e1414db4a42ad62f07d1c7a7624" }

2024-06-25 21:14:02.816 DEBUG (MainThread) [homeassistant.components.google_assistant.smart_home] Processing message: {'inputs': [{'context': {'locale_country': 'US', 'locale_language': 'en'}, 'intent': 'action.devices.EXECUTE', 'payload': {'commands': [{'devices': [{'id': 'alarm_control_panel.home'}], 'execution': [{'challenge': {'pin': '****'}, 'command': 'action.devices.commands.ArmDisarm', 'params': {'arm': False}}]}]}}], 'requestId': '39298766513567840'} 2024-06-25 21:14:02.818 DEBUG (MainThread) [homeassistant.components.google_assistant.smart_home] Response: {'commands': [{'ids': ['alarm_control_panel.home'], 'states': {'currentArmLevel': 'armed_home', 'isArmed': True, 'online': True}, 'status': 'SUCCESS'}]} 2024-06-25 21:14:03.066 WARNING (SyncWorker_20) [custom_components.truenas.truenas_api] TrueNAS trueearth.lab.awptechnologies.co unable to fetch data "reporting/get_data" (422) 2024-06-25 21:14:03.515 DEBUG (MainThread) [homeassistant.components.google_assistant.report_state] Scheduling report state for alarm_control_panel.home: {'online': True, 'isArmed': False, 'currentArmLevel': 'armed_home'} 2024-06-25 21:14:04.632 DEBUG (MainThread) [homeassistant.components.google_assistant.http] Response on https://homegraph.googleapis.com/v1/devices:reportStateAndNotification with data {'requestId': '2bda2cc3889b43cbae13b866a567ed94', 'agentUserId': 'a9286e6a47ef40e4a8b9845de088fc24', 'payload': {'devices': {'states': {'alarm_control_panel.home': {'online': True, 'isArmed': False, 'currentArmLevel': 'armed_home'}}}}} was { "requestId": "2bda2cc3889b43cbae13b866a567ed94" }

awptechnologies commented 6 days ago

Sorry there are some other logs mixed in but this is the log output. google still tells me there is an error but it successfully arms. and when disarming google says there is an error but it disarms.

awptechnologies commented 6 days ago

This also pops up in homeassistant logs

Logger: homeassistant.helpers.frame Source: helpers/frame.py:184 First occurred: 10:01:54 AM (10 occurrences) Last logged: 10:02:27 AM

Detected that custom integration 'alarmo' calls async_forward_entry_setup for integration, alarmo with title: Alarmo and entry_id: cc12201f920520a9d169bc6db888658d, which is deprecated and will stop working in Home Assistant 2025.6, await async_forward_entry_setups instead at custom_components/alarmo/__init__.py, line 80: hass.async_create_task(, please create a bug report at https://github.com/nielsfaber/alarmo/issues
Detected that custom integration 'alarmo' calls hass.http.register_static_path which is deprecated because it does blocking I/O in the event loop, instead call `await hass.http.async_register_static_path([StaticPathConfig("/api/panel_custom/alarmo", "/config/custom_components/alarmo/frontend/dist/alarm-panel.js", False)])`; This function will be removed in 2025.7 at custom_components/alarmo/panel.py, line 27: hass.http.register_static_path(, please create a bug report at https://github.com/nielsfaber/alarmo/issues
Baldhor commented 6 days ago

Sorry there are some other logs mixed in but this is the log output. google still tells me there is an error but it successfully arms. and when disarming google says there is an error but it disarms.

Google home error message when arming require the fix I proposed above, and @nielsfaber plan to add it in next release. Google home error message when disarming require to change how the disarm command is handled, it's harder work and out of my capabilities. Maybe Nielsfaber will have some ideas => processing is actually asynchronous, it must be syncrhonous.

Nothing in your logs would explain the "not connected issue".