8000 InfluxDB datetime to float TypeError after #7879 · Issue #8042 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

InfluxDB datetime to float TypeError after #7879 #8042

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

Closed
mezz64 opened this issue Jun 15, 2017 · 4 comments · Fixed by #8080
Closed

InfluxDB datetime to float TypeError after #7879 #8042

mezz64 opened this issue Jun 15, 2017 · 4 comments · Fixed by #8080

Comments

@mezz64
Copy link
Contributor
mezz64 commented Jun 15, 2017

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):
Latest dev. with commit #7879.

Python release (python3 --version):
3.6

Component/platform:
InfluxDB

Description of problem:
After the merge of #7879 I get errors on start related to converting a datetime to float. I have my hass clock based sensors excluded in my config, makes no difference. Doesn't seem to reoccur after start.

Expected:
No errors.

Problem-relevant configuration.yaml entries and steps to reproduce:

influxdb:
  host: 192.168.11.5
  port: 8082
  exclude:
    entities:
      - sensor.date
      - sensor.time
      - sensor.hass_uptime
      - sensor.runtime_today

Traceback (if applicable):

2017-06-15 10:17:14 ERROR (Thread-5) [homeassistant.core] Error doing job: Future exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/components/influxdb.py", line 164, in influx_event_listener
    json_body[0]['fields'][key] = float(value)
TypeError: float() argument must be a string or a number, not 'datetime.datetime'

During handling of the above exception, another exception occurred:

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/influxdb.py", line 170, in influx_event_listener
    non_decimal.sub('', value))
TypeError: expected string or bytes-like object
2017-06-15 10:17:14 INFO (MainThread) [homeassistant.core] Bus:Handling <Event state_changed[L]: entity_id=automation.washer_power_to_mqtt, old_state=<state automation.washer_power_to_mqtt=off; last_triggered=None, friendly_name=Washer power to MQTT @ 2017-06-15T10:17:12.718642-04:00>, new_state=<state automation.washer_power_to_mqtt=on; last_triggered=None, friendly_name=Washer power to MQTT @ 2017-06-15T10:17:14.374405-04:00>>
2017-06-15 10:17:14 ERROR (Thread-5) [homeassistant.core] Error doing job: Future exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/components/influxdb.py", line 164, in influx_event_listener
    json_body[0]['fields'][key] = float(value)
TypeError: float() argument must be a string or a number, not 'datetime.datetime'

During handling of the above exception, another exception occurred:

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/influxdb.py", line 170, in influx_event_listener
    non_decimal.sub('', value))
TypeError: expected string or bytes-like object

Additional info:

@mezz64
Copy link
Contributor Author
mezz64 commented Jun 15, 2017

I was also incorrect in my initial report, as the error does persist after startup. It occurs in multiples of 2 and somewhat random frequency, but as close as 30s apart.

@dale3h
Copy link
Member
dale3h commented Jun 17, 2017

I am getting a similar error after upgrading to 0.47.0, but mine is trying to convert a string to float:

2017-06-17 17:41:10 ERROR (MainThread) [homeassistant.core] Error doing job: Future exception was never retrieved
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/influxdb.py", line 164, in influx_event_listener
    json_body[0]['fields'][key] = float(value)
ValueError: could not convert string to float: '0.12 0.24 0.20 2/387 3'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/usr/lib/python3.5/concurrent/futures/thread.py", line 55, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.5/site-packages/homeassistant/components/influxdb.py", line 170, in influx_event_listener
    non_decimal.sub('', value))
ValueError: could not convert string to float: '0.120.240.2023873'

@mezz64
Copy link
Contributor Author
mezz64 commented Jun 18, 2017

I don't think the regex match is strict enough, so it's catching characters within a string as well as at the end. I'm wondering if this should just be reverted since the original problem it was added to fix has been corrected separately in #8069.

@philhawthorne
Copy link
Contributor

Yeah looks like the Regex is expecting a string.

I'll add a PR to ignore datetime values

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

Successfully merging a pull request may close this issue.

3 participants
0