Code Monkey home page Code Monkey logo

teslamate-telegram-bot's Issues

UnboundLocalError: cannot access local variable 'message_text' where it is not associated with a value

v0.7.3 runs on test system, fails on production with:

teslamatetelegrambot | Traceback (most recent call last):
teslamatetelegrambot | File "/app/./src/teslamate_telegram_bot.py", line 227, in
teslamatetelegrambot | asyncio.run(main())
teslamatetelegrambot | File "/usr/local/lib/python3.12/asyncio/runners.py", line 194, in run
teslamatetelegrambot | return runner.run(main)
teslamatetelegrambot | ^^^^^^^^^^^^^^^^
teslamatetelegrambot | File "/usr/local/lib/python3.12/asyncio/runners.py", line 118, in run
teslamatetelegrambot | return self._loop.run_until_complete(task)
teslamatetelegrambot | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
teslamatetelegrambot | File "/usr/local/lib/python3.12/asyncio/base_events.py", line 685, in run_until_complete
teslamatetelegrambot | return future.result()
teslamatetelegrambot | ^^^^^^^^^^^^^^^
teslamatetelegrambot | File "/app/./src/teslamate_telegram_bot.py", line 205, in main
teslamatetelegrambot | await check_state_and_send_messages(bot, chat_id)
teslamatetelegrambot | File "/app/./src/teslamate_telegram_bot.py", line 172, in check_state_and_send_messages
teslamatetelegrambot | await send_telegram_message_to_chat_id(bot, chat_id, message_text)
teslamatetelegrambot | ^^^^^^^^^^^^
teslamatetelegrambot | UnboundLocalError: cannot access local variable 'message_text' where it is not associated with a value
teslamatetelegrambot exited with code 0

Proof of Concept

As a user I want to be informed when an update is available for my Tesla car. This can be done by messaging service to my mobile.

I do not want do have a full weight automation such as Openhab2, HomeAssist, NodeRed, ... running.

`car_id` 'int' object has no attribute 'isdigit'

After upgrading to v0.7.2 I am getting the following error (with and without setting the CAR_ID env variable):

teslamate-teslamatetelegrambot-1  | Traceback (most recent call last):
teslamate-teslamatetelegrambot-1  |   File "/app/./src/teslamte_telegram_bot.py", line 64, in <module>
teslamate-teslamatetelegrambot-1  |     if not car_id.isdigit() or int(car_id) < 1:
teslamate-teslamatetelegrambot-1  |            ^^^^^^^^^^^^^^
teslamate-teslamatetelegrambot-1  | AttributeError: 'int' object has no attribute 'isdigit'
teslamate-teslamatetelegrambot-1  | Traceback (most recent call last):
teslamate-teslamatetelegrambot-1  |   File "/app/./src/teslamte_telegram_bot.py", line 64, in <module>
teslamate-teslamatetelegrambot-1  |     if not car_id.isdigit() or int(car_id) < 1:
teslamate-teslamatetelegrambot-1  |            ^^^^^^^^^^^^^^
teslamate-teslamatetelegrambot-1  | AttributeError: 'int' object has no attribute 'isdigit'
teslamate-teslamatetelegrambot-1  | Traceback (most recent call last):
teslamate-teslamatetelegrambot-1  |   File "/app/./src/teslamte_telegram_bot.py", line 64, in <module>
teslamate-teslamatetelegrambot-1  |     if not car_id.isdigit() or int(car_id) < 1:
teslamate-teslamatetelegrambot-1  |            ^^^^^^^^^^^^^^
teslamate-teslamatetelegrambot-1  | AttributeError: 'int' object has no attribute 'isdigit'
teslamate-teslamatetelegrambot-1  | Traceback (most recent call last):
teslamate-teslamatetelegrambot-1  |   File "/app/./src/teslamte_telegram_bot.py", line 64, in <module>
teslamate-teslamatetelegrambot-1  |     if not car_id.isdigit() or int(car_id) < 1:
teslamate-teslamatetelegrambot-1  |            ^^^^^^^^^^^^^^
teslamate-teslamatetelegrambot-1  | AttributeError: 'int' object has no attribute 'isdigit'
teslamate-teslamatetelegrambot-1  | Traceback (most recent call last):
teslamate-teslamatetelegrambot-1  |   File "/app/./src/teslamte_telegram_bot.py", line 64, in <module>
teslamate-teslamatetelegrambot-1  |     if not car_id.isdigit() or int(car_id) < 1:
teslamate-teslamatetelegrambot-1  |            ^^^^^^^^^^^^^^
teslamate-teslamatetelegrambot-1  | AttributeError: 'int' object has no attribute 'isdigit'
teslamate-teslamatetelegrambot-1  | Traceback (most recent call last):
teslamate-teslamatetelegrambot-1  |   File "/app/./src/teslamte_telegram_bot.py", line 64, in <module>
teslamate-teslamatetelegrambot-1  |     if not car_id.isdigit() or int(car_id) < 1:
teslamate-teslamatetelegrambot-1  |            ^^^^^^^^^^^^^^
teslamate-teslamatetelegrambot-1  | AttributeError: 'int' object has no attribute 'isdigit'

Btw: there is a typo in the filename teslamte_telegram_bot.py

Question, Not an Issue

Hi @JakobLichterfeld,

Can you please let me know how different this notification is when compared to the official Tesla app sending a notification about an available update?

config-with-files

Thanks for the python implemantation (#2), to edit the source code for my own config is not the prefered way. Can we have the confi in one or more additional files?

MQTT namespace variable

Its possible to define a mqtt namespace variable in teslamate.

MQTT_NAMESPACE=

If it is defined, the telegram bot won't notify the update, because its looking in a wrong topic.

teslamate/$namespace/cars/2/inside_temp

would work then.

If environment variable validation fails, CPU usage is very high

Today after updating to version 0.7.2 and 0.7.3, which caused issues #33 and #35, my server CPU usage was constantly at >90%. Probably there is an endless loop running trying to validate the config again and again.
After I stopped the (broken) teslamatetelegrambot container, CPU usage returned to normal:

Screenshot 2024-03-21 at 13 43 11

Python implementation

The proof of conecpt (#1) shows it works, perfect.
Let us implement it in python, as there are libraries for mqtt and telegram bot available for cool features in the future.

feat: allow negative chat_id, which means group chats

After upgrading to v0.7.3 I am now getting this error:

ERROR - Error: Please set the environment variable TELEGRAM_BOT_CHAT_ID to a valid number and try again.

My env variable:

TELEGRAM_BOT_CHAT_ID=-410996XXX

XXX are more digits, removed for privacy. I guess the issue is that it is a negative number. Also doesn't work if I wrap it in double quotes.

deployment-as-docker

Thanks for config with files (#4). It would be cool to have it as a docker container, so no need to take care about requirments and so on as a user.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.