FutureTense/keymaster

ISSUE: problems with telegram notification service

JABeaver opened this issue · 6 comments

Describe the bug
Notifications are not working properly. it appears to be called but does not work. I have the notification set up in other automations and those work. I can call it manually through the developer tools and that also works but for some reason when it's called from keymaster it won't work.

Environment (please complete the following information):

  • OS: ubuntu 22.04 lts
  • Type of system that HA is running on: Dell Optiplex
  • Home Assistant version: 2022.11.1
  • Hassio/Docker/Core? Docker Compose
  • Component version: keymaster v0.0.83
  • Z-Wave integration name: Z-Wave JS
  • Lock make and model: Kwikset Obsidian 954 (Kwikset 99540-002 Obsidian)

Logs

keymaster_front_door_manual_notify turned off triggered by automation keymaster_front_door Lock Notifications triggered by event 'keymaster_lock_state_changed'
8:39:33 AM - 1 hour ago
keymaster_front_door_manual_notify turned on triggered by automation keymaster_front_door Lock Notifications triggered by event 'keymaster_lock_state_changed'
8:39:33 AM - 1 hour ago
keymaster_front_door_manual_notify started triggered by automation keymaster_front_door Lock Notifications triggered by event 'keymaster_lock_state_changed'
8:39:33 AM - 1 hour ago - Traces
keymaster_front_door_timer_canceled triggered by event 'timer.cancelled'
8:39:33 AM - 1 hour ago - Traces
keymaster_front_door Lock Notifications triggered by event 'keymaster_lock_state_changed'
8:39:33 AM - 1 hour ago - Traces
Touchscreen Electronic Deadbolt fired Notification CC 'notification' event 'Access Control': 'RF lock operation'
8:39:33 AM - 1 hour ago
keymaster_turn_off_retry_front_door triggered by service lock.lock
8:39:33 AM - 1 hour ago - Traces
keymaster_front_door_locked triggered by service lock.lock
8:39:33 AM - 1 hour ago - Traces
boltchecked_front_door was locked triggered by service lock.lock
8:39:33 AM - 1 hour ago - Jason Beaver
Touchscreen Electronic Deadbolt was locked triggered by service lock.lock
8:39:33 AM - 1 hour ago - Jason Beaver
keymaster_front_door_manual_notify turned off triggered by automation keymaster_front_door Lock Notifications triggered by event 'keymaster_lock_state_changed'
8:39:29 AM - 1 hour ago
keymaster_front_door_manual_notify turned on triggered by automation keymaster_front_door Lock Notifications triggered by event 'keymaster_lock_state_changed'
8:39:29 AM - 1 hour ago
keymaster_front_door_manual_notify started triggered by automation keymaster_front_door Lock Notifications triggered by event 'keymaster_lock_state_changed'
8:39:29 AM - 1 hour ago - Traces
keymaster_front_door Lock Notifications triggered by event 'keymaster_lock_state_changed'
8:39:29 AM - 1 hour ago - Traces
boltchecked_front_door was unlocked triggered by service lock.unlock
8:39:29 AM - 1 hour ago - Jason Beaver
Touchscreen Electronic Deadbolt fired Notification CC 'notification' event 'Access Control': 'RF unlock operation'
8:39:29 AM - 1 hour ago
Touchscreen Electronic Deadbolt was unlocked triggered by service lock.unlock
8:39:29 AM - 1 hour ago - Jason Beaver

Screenshots
HA_Screenshot

Additional context
relevant sections of files...
scripts.yaml

keymaster_front_door_manual_notify:
  mode: parallel
  sequence:
  - service: notify.telegram
    data:
      title: '{{ title }}'
      message: '{{ message }}'
  icon: mdi:bell
  max: 3

configuration.yaml

notify:
  - platform: telegram
    name: telegram
    chat_id: !secret telegram_bot_chat_id

telegram_bot:
  - platform: polling
    api_key: !secret telegram_bot_api_key
    allowed_chat_ids:
      - !secret telegram_bot_chat_id

I'm sure it's something simple because I had an SMPT notify working previously in keymaster but it was unreliable so I am trying to use telegram. and as I said in the beginning I can call notify.telegram manually and it works fine so it must be something to do with the automation in keymaster.

Based on your trace it looks like the script was called and the variables injected, check your home-assistant.log for telegram errors, also verify the correct data that the telegram service needs to send a message.

I cleared the log, restarted HA and then unlocked and locked the door lock via HA dashboard. here is the result of the home-assistant.log

2023-01-23 02:43:59.016 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration keymaster which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-01-23 02:43:59.017 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration frigate which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-01-23 02:43:59.017 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration nodered which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-01-23 02:43:59.017 WARNING (SyncWorker_0) [homeassistant.loader] We found a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2023-01-23 02:44:32.048 ERROR (SyncWorker_1) [homeassistant.components.telegram_bot] Error sending message: Can't parse entities: can't find end of the entity starting at byte offset 5. Args: (chat id redacted, 'front_door\nRF unlock operation'), kwargs: {'parse_mode': 'Markdown', 'disable_web_page_preview': None, 'disable_notification': False, 'reply_to_message_id': None, 'reply_markup': None, 'timeout': None}
2023-01-23 02:44:33.699 ERROR (SyncWorker_4) [homeassistant.components.telegram_bot] Error sending message: Can't parse entities: can't find end of the entity starting at byte offset 5. Args: (chat id redacted, 'front_door\nRF lock operation'), kwargs: {'parse_mode': 'Markdown', 'disable_web_page_preview': None, 'disable_notification': False, 'reply_to_message_id': None, 'reply_markup': None, 'timeout': None}

I don't know if it helps but I turned on debug logging for telegram and keymaster and got this additional entry

2023-01-23 03:08:29.141 DEBUG (MainThread) [homeassistant.components.telegram_bot] New telegram message send_message: {'target': [chat_id_redacted], 'title': 'front_door', 'message': 'RF lock operation'}
2023-01-23 03:08:29.141 DEBUG (SyncWorker_0) [homeassistant.components.telegram_bot] Send message in chat ID chat_id_redacted with params: {'parse_mode': 'Markdown', 'disable_notification': False, 'disable_web_page_preview': None, 'reply_to_message_id': None, 'reply_markup': None, 'timeout': None, 'message_tag': None}
2023-01-23 03:08:30.207 ERROR (SyncWorker_0) [homeassistant.components.telegram_bot] Error sending message: Can't parse entities: can't find end of the entity starting at byte offset 5. Args: (chat_id_redacted, 'front_door\nRF lock operation'), kwargs: {'parse_mode': 'Markdown', 'disable_web_page_preview': None, 'disable_notification': False, 'reply_to_message_id': None, 'reply_markup': None, 'timeout': None}

Review the format for the service call for telegram notifications and update your script accordingly.

I found the fix on some other page. this is some sort of issue between the telegram_bot integration and third-party integrations. you need to insert parse_mode: html into the bot config in configuration.yaml

telegram_bot:
  - platform: polling
    parse_mode: html
    api_key: !secret telegram_bot_api_key
    allowed_chat_ids:
      - !secret telegram_bot_chat_id

I don't understand why the integrations have issues with the telegram_bot when you can call it manually and when you create an automation. I assume it has something to do with the way the variables are passed. perhaps you can shed some light on this for me.

No idea, never used telegram.