der-optimist / hass

17 stars 3 forks source link

Telegram Special Bot - Automation and Component Alert event #1

Open dakweenduck opened 3 years ago

dakweenduck commented 3 years ago

Trying to use the "special_bot" target to trigger event from HA automations, but facing an error:

Automations Config in automations.yaml:

Below is the error output.

The app receives the "custom_notify" event but it appears to be issue with args passed:

2020-11-29 09:00:22.644857 INFO AppDaemon: Loading App Module: /config/appdaemon/apps/custom_notify.py 2020-11-29 09:00:22.648762 INFO AppDaemon: Initializing app custom_notify using class custom_notify from module custom_notify 2020-11-29 09:00:22.784965 INFO AppDaemon: App initialization complete 2020-11-29 09:00:31.976747 WARNING custom_notify: ------------------------------------------------------------ 2020-11-29 09:00:31.977942 WARNING custom_notify: Unexpected error in worker for App custom_notify: 2020-11-29 09:00:31.978749 WARNING custom_notify: Worker Ags: {'id': 'xxxxxxxx', 'name': 'custom_notify', 'objectid': 'xxxxx, 'type': 'event', 'event': 'custom_notify', 'function': <bound method custom_notify.notification_received of <custom_notify.custom_notify object at 0x7f3a6c32eaf0>>, 'data': {'customData': [{'message': 'Test'}, {'target': 'special_bot'}, {'special_bot_api_key': '1111111111:aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'}, {'special_bot_chat_id': '1111111111'}]}, 'pin_app': True, 'pin_thread': 1, 'kwargs': {'__thread_id': 'thread-1'}} 2020-11-29 09:00:31.979506 WARNING custom_notify: ------------------------------------------------------------ 2020-11-29 09:00:31.986511 WARNING custom_notify: Traceback (most recent call last): File "/usr/lib/python3.8/site-packages/appdaemon/threading.py", line 933, in worker funcref(args["event"], data, self.AD.events.sanitize_event_kwargs(app, args["kwargs"])) File "/config/appdaemon/apps/custom_notify.py", line 27, in notificationreceived data["message"] = data["message"].replace(""," ").replace("*"," ") KeyError: 'message' 2020-11-29 09:00:31.986884 WARNING custom_notify: ------------------------------------------------------------

Any ideas and could you perhaps point me in right direction?

Also is it possible to use "Special_bot" target in a HA component "alert"?

What should the "notify" config look like for "special_bot" (not sure how it calls the event "custom_notify") and a bit confused as to how to add the special_bot_api_key and special_bot_chat_id for notify?

notify:

Config in configuration.yaml:

alert: garage_door_open_long: name: Main Gate LEFT OPEN!!! entity_id: sensor.MainGate_Open state: 'True'
repeat: 1 can_acknowledge: true # Optional, default is true skip_first: true # Optional, false is the default notifiers:

Tried going through your configuration.yaml and all apps for hints but no luck, would appreciate your help.

Default telegram bot works fine.

Rotif commented 1 year ago

I have the same problem, pleas could somebody give me hint? Thank you