Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

State_trigger float/int conversion of entity_ids that start with a number_number #551

Open
ALERTua opened this issue Dec 1, 2023 · 1 comment

Comments

@ALERTua
Copy link
Contributor

ALERTua commented Dec 1, 2023

Glances integration adds generated entity_ids based on the host, provided as a Glances Server.
For example, adding a Glances integration using my Unraid server hostname
image
generates entity_ids like sensor.server_hostname_package_id_0_temperature.
But if I add the Glances server by the IP address
image
Such entity becomes sensor.192_168_1_3_package_id_0_temperature, and Pyscript cannot parse state_trigger condition float conversions based on this entity_id with SyntaxError: invalid decimal literal

This can be proven by creating a Number Helper input_number.123_465_number
image
that will fail any state_trigger that tries to convert its value to float or int

2023-12-01 14:05:41.156 ERROR (MainThread) [custom_components.pyscript.file.tryouts.tryouts] Exception in <file.tryouts.tryouts @state_trigger()> line 1:
    float(input_number.123_465_number)
                              ^
SyntaxError: invalid decimal literal (file.tryouts.tryouts @state_trigger(), line 1)
@ALERTua ALERTua changed the title Glances dynamic ip-address-based entity_ids State_trigger float/int conversion of entity_ids that start with a number_number Dec 1, 2023
@dmamelin
Copy link

dmamelin commented Dec 5, 2023

In Python, identifiers starting with a digit are prohibited.
You should use state.get("sensor.192_168_1_3_package_id_0_temperature")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants