Closed Ilpo55 closed 1 year ago
Same issue here:
Logger: homeassistant Source: components/sensor/init.py:583 First occurred: 11:54:51 (12 occurrences) Last logged: 12:15:26
Error doing job: Task exception was never retrieved Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/sensor/init.py", line 579, in state numerical_value = int(value) ValueError: invalid literal for int() with base 10: ''
The above exception was the direct cause of the following exception:
Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/template_entity.py", line 379, in _async_template_startup result_info.async_refresh() File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 953, in async_refresh self._refresh(None) File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 1133, in _refresh self.hass.async_run_hass_job(self._job, event, updates) File "/usr/src/homeassistant/homeassistant/core.py", line 607, in async_run_hass_job hassjob.target(*args) File "/usr/src/homeassistant/homeassistant/helpers/template_entity.py", line 348, in _handle_results self.async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 585, in async_write_ha_state self._async_write_ha_state() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 649, in _async_write_ha_state state = self._stringify_state(available) File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 591, in _stringify_state if (state := self.state) is None: File "/usr/src/homeassistant/homeassistant/components/sensor/init.py", line 583, in state raise ValueError( ValueError: Sensor sensor.shf_electricity_price_now has device class monetary, state class None unit €/kWh and suggested precision None thus indicating it has a numeric value; however, it has the non-numeric value: (<class 'str'>)
After HA update to version 2023.5.0 "sensor.shf_electricity_price_now" is unknown. I replaced line
state: '{{ state_attr("sensor.shf_electricity_price_now", "today_prices")[now().hour] }}'
with linestate: '{{ state_attr("sensor.shf_electricity_price", "data")[now().hour]["PriceWithTax"]}}'
Now it works. Is that fix OK?
Works for me too.
The fix seems to miss the additional "input_number.shf_price1_slider" price overhead which you can use to add in margin, transport and tax.
The fix seems to miss the additional "input_number.shf_price1_slider"
I think that the problem is with "SHF Control Factor " Can you test if you modify that part of the yaml. Original line is commented.
- sensor:
- name: SHF Control Factor 0-1
unique_id: shf_control_factor_0-1
unit_of_measurement: factor
icon: mdi:gauge
state: '{{ (states("sensor.shf_control_factor_1") | float /2 + 0.5) | default(0) }}'
# state: '{{ (states("sensor.shf_control_factor_1") | float /2 + 0.5) | default("Unknown") }}'
and
- sensor:
- name: SHF Control Factor +-1
unique_id: shf_control_factor_+-1
unit_of_measurement: factor
icon: mdi:gauge
state: '{{ state_attr("sensor.shf_control_factor_1", "today_values")[now().hour] | default(0) }}'
# state: '{{ state_attr("sensor.shf_control_factor_1", "today_values")[now().hour] | default("Unknown") }}'
I don't use extra prices so I don't have that part of code in my yaml.
I'm not using the control factor so can't comment on that. I just noticed that the fix takes data from a different attribute array versus the original, which doesn't include the overheads. For now I have compensated elsewhere for the lack of extra prices - no problem for automation logic but will make the interface display wrong prices.
I'm not using the control factor so can't comment on that. I just noticed that the fix takes data from a different attribute array versus the original, which doesn't include the overheads.
Yes, you are right. Let's hope that Teemu will have time to fix this.
For me the SHF Electricity price now shows also wrong value. I used SHF Price1, but now after the fix above it doesn't do anything. Still picks the cheapest hours, so I can manage with the wrong value. EDIT: After second fix:
- sensor:
- name: SHF Control Factor +-1
unique_id: shf_control_factor_+-1
unit_of_measurement: factor
icon: mdi:gauge
state: '{{ state_attr("sensor.shf_control_factor_1", "today_values")[now().hour] | default(0) }}'
# state: '{{ state_attr("sensor.shf_control_factor_1", "today_values")[now().hour] | default("Unknown") }}'
The SHF Electricity price now seem to be right, but SHF Price1 affects only to the SHF Average price today, not the SHF Electricity price now value.
I used SHF Price1, but now after the fix above it doesn't do anything.
What do you say about this fix?
# state: '{{ state_attr("sensor.shf_electricity_price", "data")[now().hour]["PriceWithTax"]}}'
state: >
{% set p_now = (state_attr("sensor.shf_electricity_price", "data")[now().hour]["PriceWithTax"]) | float %}
{% set p_now = p_now + states('input_number.shf_price1_slider') | float %}
{{ p_now}}
I used SHF Price1, but now after the fix above it doesn't do anything.
What do you say about this fix?
... That's what I needed, thanks Ilpo! For me, everything seem to be working with these fixes. Is there still something broken?
This looks like an ok temp fix for the price1 but I'd still hope that @T3m3z will find the time to restore original functionality which includes support for variable transport costs which is needed for some providers (maybe something else I'm not aware of too).
Edit: I found that today this second fix is giving incorrect results (maybe taking from wrong day's prices as basis?), will revert to the previous version and see if it's better.
tried to fix like this.
# state: '{{ state_attr("sensor.shf_electricity_price_now", "today_prices")[now().hour] }}'
state: '{{ state_attr("sensor.shf_electricity_price_now", "today_prices")[now().hour] | default(none) }}'
tried to fix like this.
# state: '{{ state_attr("sensor.shf_electricity_price_now", "today_prices")[now().hour] }}' state: '{{ state_attr("sensor.shf_electricity_price_now", "today_prices")[now().hour] | default(none) }}'
That is better than my fix!
is there now a fix that will retain all the functionalities? To be honest i dont use any overheads or so but would still rather wait for the proper fix as i collect history data and dont want to notice after days that it was off anyway
Sorry for the extremely long delay. I hope that version 0.1.11 fixes this bug. Fix seems to work on my test HomeAssistant instance. Please reopen this if the problem persists.
After HA update to version 2023.5.0 "sensor.shf_electricity_price_now" is unknown. I replaced line
state: '{{ state_attr("sensor.shf_electricity_price_now", "today_prices")[now().hour] }}'
with linestate: '{{ state_attr("sensor.shf_electricity_price", "data")[now().hour]["PriceWithTax"]}}'
Now it works. Is that fix OK?