-
Notifications
You must be signed in to change notification settings - Fork 113
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
Not able to use template sensors for additional costs logic #356
Comments
It could be a race condition. Try removing the sensor without the template |
Thanks for your reply! The 3_10_025 is added via the Integrations in the GUI. Is there a way to delete this? I can only see that it is possible to disable the device. The 3_095_0 is added via sensors.yaml I need both sensors. How can I add two without ending up with this condition? Edit: Tried to dele the 3_10_025 via the GUI, resulting in the complete integration being removed, and the 3_095_0 not being available until adding a new sensor via the GUI. |
After doing some more testing, it seems quite clear that the issue is the use of states from other sensors, not a race condition. At least not a race condition between the two Nordpool sensors. If I include any states sensor in the declaration of "s"-variables, the 3_095_0 sensor will generate the error "No data for today, unable to set attrs". The same happens if I add any states sensor directly to the logic. If I however replace the states sensors with a number, everything seems to work perfect. If I test the logic in the "Templates" section under "Development Tools" it works as expected, even with states sensors. |
Hm, Im still not convinced that it isn’t a race condition. With both sensors present. Provide logs of startup and when price updates changes to unknown. With only the template sensor. Provide logs of startup and when price updates changes to unknown. To verify if the issue is related to the other sensor. Create a simpler template that adds a number for example 100. After the price updates due to new hour, change to 1000 and wait for a new price update. Provide the logs Provide logs |
Thank you! I have done my best to provide logs as you request. The price changes to unkown once I restart. Log from both sensors present:
After deleting the 3_10_025. The sensors seems to update in the logs, but the entity is unavailable:
Startup log and log after first change of hour after chaning the template to "{{ 100 | float }}". After this change, the 3_095_0 entity is now available, showing the price as expected, also after change of hour.
I changed the value of additional cost from 100 to 1000 in the sensor.yaml at 14:04, without doing any restart or reload of the yaml configuration. After change of hour from 14 to 15, the additional cost of 1000 was not used by the 3_095_0 entity, as this is still at approximately 100. This is the log from change of hour from 14 to 15:
After reboot with additional cost of 1000 in sensor.yaml. The 3_095_0 entity now included the additional cost of 1000.
Edit: Logs from hour shift with additional cost of 1000
|
Version of the custom_component
0.0.14
Homeassistant version
2023.11.3
Configuration
Describe the bug
For the additional costs, I want to use the numbers from two template sensors as part of the conditions in an if statement. The numbers indicate the hour when the sun rises and sets on my solar panels. If I declare these variables directly as numbers (i.e. sets "solar_start": 10 and "solar_end": 13) , the daily price is calculated as expected. However, if I replace these number with variables, (insert sensor.solar_start and sensor.solar_end as given in the code above), the nordpool sensor only gets "unkown" values.
If I reload the Nordpool integration, the sensor is working as expected, indicating that the logic is generally working. However, when I receive new prices, the sensor is not updated, and thus this is not a solution that can be used on a daily basis.
The sensor from the yaml-configuration is the nordpool_kwh_krsand_nok_3_095_0
Debug log
The text was updated successfully, but these errors were encountered: