Make sure you are running the latest version of Home Assistant before reporting an issue.
You should only file an issue if you found a bug. Feature and enhancement requests should go in the Feature Requests section of our community forum:
Home Assistant release (hass --version):
0.49.1
Python release (python3 --version):
3.6
Component/platform:
Prometheus Component, HA running latest Docker image
Description of problem:
2017-07-26 08:05:32 ERROR (SyncWorker_9) [homeassistant.core] Error doing job: Future exception was never retrieved
Traceback (most recent call last):
File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 55, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/src/app/homeassistant/components/prometheus.py", line 87, in handle_event
getattr(self, handler)(state)
File "/usr/src/app/homeassistant/components/prometheus.py", line 134, in _handle_device_tracker
value = state_helper.state_as_number(state)
File "/usr/src/app/homeassistant/helpers/state.py", line 213, in state_as_number
return float(state.state)
ValueError: could not convert string to float: 'Zone Name'
Expected:
No errors?
Problem-relevant configuration.yaml entries and steps to reproduce:
Traceback (if applicable):
Additional info:
Can you share your configuration.yaml? and dockerfile...
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment :+1:
If that can help, I can't see this error anymore on my side.
but I recently changed many things (raspbian jessie to stretch, python 3.4 to 3.6.3 and hass 0.56 to 0.57.2) so I'm not sure about which one helped on fixing the issue.
Home Assistant release (hass --version):
0.57.2
Python release (python3 --version):
Python 3.6.3
Actually, I can still see those errors in HA logs.
I didn't notice them because I had to stay home for quite a while but these errors only occur when owntracks reports me to be in a defined zone outside other than my 'home'.
Home Assistant release (hass --version):
0.60.0
Python release (python3 --version):
3.6.3
2017-12-19 15:19:00 ERROR (MainThread) [homeassistant.core] Error doing job: Future exception was never retrieved
Traceback (most recent call last):
File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run
result = self.fn(*self.args, **self.kwargs)
File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/prometheus.py", line 87, in handle_event
getattr(self, handler)(state)
File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/prometheus.py", line 134, in _handle_device_tracker
value = state_helper.state_as_number(state)
File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/state.py", line 221, in state_as_number
return float(state.state)
ValueError: could not convert string to float: 'work'
Here is a sample of my configuration:
prometheus:
device_tracker:
- platform: owntracks
max_gps_accuracy: 200
waypoints: True
zone:
- name: wong
latitude: xxx.xxxxxxxx
longitude: xxx.xxxxxxxxx
radius: 250
icon: mdi:subway
- name: work
latitude: xxx.xxxxxxxx
longitude: xxx.xxxxxxx
radius: 250
icon: mdi:tie
- name: home
latitude: xxx.xxxxxxxx
longitude: xxx.xxxxxxxx
radius: 300
icon: mdi:home
Also happens in the last 0.61.1
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment :+1:
Unfortunately, the issue is still present in 0.66
Present in 0.67.1
I solved the problem for now by hacking const.py (adding the state for the zone as a const) and then also helpers/state.py by adding the const that I created in the const.py file. The error is that when you enter a zone which is not treated as home or not_home it can't find it as the state_as_number only takes know states (below you can see my created state STATE_WORK:
if state.state in (STATE_ON, STATE_LOCKED, STATE_ABOVE_HORIZON,
STATE_OPEN, STATE_HOME, STATE_HEAT, STATE_COOL, STATE_WORK
return 1
if state.state in (STATE_OFF, STATE_UNLOCKED, STATE_UNKNOWN,
STATE_BELOW_HORIZON, STATE_CLOSED, STATE_NOT_HOME,
STATE_IDLE):
This is still borked in 76.2 and @greberg is spot on with the error here.
The function state_as_number tries to cast any undefined state into a float, which clearly does not work for strings.
I'd hand in a pull request for this except I'm not sure how to best solve this problem. Clearly people are going to define their own zone names, and as long as we try to cast them to floats that will not work. The only suggestion I can think of is to set state to a value indicating that you're in a zone or not (1=in zone / 0=not in zone) and move the zone name to an attribute. I suspect this would break a lot of things dependent on how zones work today though.
I'm getting this in my logs as well.
@tcastberg Could that be done only for what Prometheus sees/outputs?
@cyberjacob Unfortunately not. We do want the value of states in prometheus, so it's a generic function that just tries to get the value of each state. Mostly that works because devices either have a numeric value for their state, or a known string. The problem with zones is that you can define your own string values for the device_tracker zones, which makes the attempt cast it into a float fail.
@balloob, any chance someone could have a look at this?
New comer to Home Assistant here, hoping to see a fix for this as well.
@tcastberg Is the generic function you mentioned specific to the Prometheus component? Either way, this could be solved by filtering/removing zone states. e.e.
if(state.isZone):
return
else
return state.getValue()
The function is not specific to Prometheus. And I for one would like to get zone states, both in Prometheus and in other components.
There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment :+1:
It's still present in 0.83.3, haven't had time to test 0.84 yet. Will do so within a day or two.
Upgraded to 0.84.2 and the issue is still present.
This is not pretty, but it gets rid of the errors in homeassistant/components/prometheus.py:
156c156,160
< value = state_helper.state_as_number(state)
---
> try:
> value = state_helper.state_as_number(state)
> except ValueError:
> _LOGGER.warning("Could not convert %s to float", state)
> value = 0
Is this something that is on the backlog or is the feature as such something that shouldn't be used? Of course I can live with the filter away error or edit the docker container const file but right now with so many releases it becomes somewhat cumbersome.
This has been inactive for a while. Is this still an issue you are experiencing? Can you please try upgrading to the latest version of Home Assistant (0.90) and report back if this is still a problem? Thanks!
Nothing have been changed in the code to actually prevent this, so yes this is still an issue
@greberg Thanks for reporting back, I'll try to take a look at this and get a fix in tomorrow.
@robbiet480 The fix I described above solves the problem. Now applies to homeassistant/components/prometheus/__init__.py. Line numbers may be incorrect.
@tcastberg Please look over my PR and approve it when you have a moment.
Done, nice that you're solving potential similar future problems. :)
Why only fix 10% of the problem spots when you can fix 100% with just a couple more pastes?