wmalgadey / tado_component

Custom home-assistant component for tado (using PyTado)
GNU General Public License v3.0
12 stars 1 forks source link

Unit problem and a question #8

Closed covrig closed 7 years ago

covrig commented 7 years ago

Again, great job. My question is, how often do you update the sensors (call the API)? I hope the thermostat will not fail. I have a small problem with this component and the influxdb platform. The error is that this platform generates the temperature as a string while the rest generate it as a float. Influx can't save them together and this results in a log FULL of errors.

homeassistant.components.influxdb: Error saving event "[{'fields': {'temperature': 21.0, 'away_mode': 'off', 'max_temp': 25.0, 'value': 'SMART_SCHEDULE', 'operation_mode': 'SMART_SCHEDULE', 'min_temp': 5.0, 'friendly_name': 'Bedroom'}, 'tags': {'entity_id': 'bedroom', 'domain': 'climate'}, 'time': datetime.datetime(2017, 1, 14, 10, 23, 39, 959694, tzinfo=<UTC>), 'measurement': '°C'}]" to InfluxDB
Traceback (most recent call last):
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/influxdb.py", line 141, in influx_event_listener
    influx.write_points(json_body)
  File "/home/homeassistant/.homeassistant/deps/influxdb/client.py", line 402, in write_points
    tags=tags)
  File "/home/homeassistant/.homeassistant/deps/influxdb/client.py", line 447, in _write_points
    expected_response_code=204
  File "/home/homeassistant/.homeassistant/deps/influxdb/client.py", line 289, in write
    headers=headers
  File "/home/homeassistant/.homeassistant/deps/influxdb/client.py", line 259, in request
    raise InfluxDBClientError(response.content, response.status_code)
influxdb.exceptions.InfluxDBClientError: 400: {"error":"field type conflict: input field \"value\" on measurement \"°C\" is type string, already exists as type float"}

Another error would be:

17-01-14 11:24:02 custom_components.climate.tado_v1: Unable to update from sensor: sensor.living_temperature
17-01-14 11:24:02 custom_components.climate.tado_v1: Unable to update from sensor: sensor.laundry_temperature
17-01-14 11:24:02 custom_components.climate.tado_v1: Unable to update from sensor: sensor.bathroom_temperature
17-01-14 11:24:02 custom_components.climate.tado_v1: Unable to update from sensor: sensor.bedroom_temperature
17-01-14 11:29:01 custom_components.climate.tado_v1: Unable to update from sensor: sensor.laundry_temperature
wmalgadey commented 7 years ago

Hi covrig!

your first problem is the same like issue #5. I had the same problem with influxdb and just added the climate-devices to the blacklist. I use the sensor._temperature for graphs in influxdb.

The second doesn't occur in my hass environment. Is there an exception documented right before the message? I just catch one type of exception (ValueError). It should occure, when the component was not able to convert the *_temperature.state to a number (states in hass seem to be always strings).

wmalgadey commented 7 years ago

For #8 and #5 I will get to the homeassistant gitter this afternoon and ask how the state of climate devices should behave. I didn't find any information on that.

covrig commented 7 years ago

@wmalgadey Thanks for the answer. I just did this and created a template sensor to read the target temperature from the climate component. I want to have a nice chart in Grafana with target temperature, current temperature and when the heater starts. Any idea if your component will crash the thermostat or the hub? I can't find any info about the refresh/update rate.

I will leave it here maybe others are interested:

  - platform: template
    sensors:
          replacethis_target:
            value_template: '{{ states.climate.replacesthis.attributes.temperature }}' 
            friendly_name: 'Whatever'
            unit_of_measurement: '°C'
wmalgadey commented 7 years ago

the target temperatur is also an attribute from sensor.<zone_name>_temperature (it is called setting). I think, templating the sensor is better, because the climate just 'listens' to the state changes from the different sensors. You may be will get a delay between sensor->climate->template

wmalgadey commented 7 years ago

SELECT mean("value") FROM "°C" WHERE "entity_id" = 'wohnzimmer_temperature' AND $timeFilter GROUP BY time($interval) fill(previous)

this is the select in grafana to query the temperature from the sensor (saved in influxdb) and

SELECT mean("setting") FROM "°C" WHERE "entity_id" = 'wohnzimmer_temperature' AND $timeFilter GROUP BY time($interval) fill(previous)

to select the setting-temperature (->mean("setting") instead of mean("value"))

covrig commented 7 years ago

@wmalgadey Thanks for the clarification and the Grafana hints. I appreciate it.

wmalgadey commented 7 years ago

does that solve your first problem for the moment? I have no luck getting some information on gitter!

I don't want to "break the hass" philosophie just by changing the state to the temperature.

And for your second problem? Is there any more detail on the error in the log?

covrig commented 7 years ago

Both errors are fixed. Sorry for not mentioning it clearly. I blacklisted the climate components from being recorded to influxdb. The climate component should not have an unit assigned, since it has multiple types of attributes in it. The way it is now, the only way it can be written to influx is as a string and that creates the error since other temperature sensors write floats.

The second error was because of a change I did in your code to fix the first one. Sorry.

wmalgadey commented 7 years ago

np! i am working on the unit/string problem :)

covrig commented 7 years ago

x