esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
290 stars 36 forks source link

Climate Core Needs To Support Setting Temperature Unit #2077

Closed mtl010957 closed 3 years ago

mtl010957 commented 3 years ago

Operating environment/Installation (Hass.io/Docker/pip/etc.):

Both Hass.io and Ubuntu pip install

ESP (ESP32/ESP8266, Board/Sonoff):

Generic D1 Mini

ESPHome version (latest production, beta, dev branch)

dev

Affected component:

Climate Core

Description of problem: In my case, HA is setup with Imperial units, making the MQTT Thermostat automatically display in Fahrenheit temperature units. I am creating a Bang-Bang temperature controller with a DS18B20 sensor, which is reading temperature in Celsius units. I need to make HA know that the sensor is in Celsius so it can automatically convert to Fahrenheit and display correctly. I am using MQTT, so I found the Bang-Bang controller is being represented in HA by an MQTT HVAC component. That component can accept a variable called temperature_unit with a value of C or F.

Problem-relevant YAML-configuration entries:

PASTE YAML FILE HERE
(These are the relevant snippets)--

sensor:
- platform: dallas
  id: "probe_1"
  address: ${probe_1_addr}
  name: "${upper_devicename} ${probe_1_addr}"
  unit_of_measurement: °C
  icon: mdi:thermometer
  device_class: temperature
  accuracy_decimals: 1
  expire_after: 600s
  filters:
    - or:
        - delta: 0.5
        - heartbeat: 300s
climate:
- platform: bang_bang
  name: "${upper_devicename} Hot Water Recirc Control"
  sensor: probe_1
  default_target_temperature_low: 38°C
  default_target_temperature_high: 44°C
  visual:
    min_temperature: 20°C
    max_temperature: 50°C

  heat_action:
    - switch.turn_on: relay_1
  idle_action:
    - switch.turn_off: relay_1

Logs (if applicable):

PASTE DEBUG LOG HERE
N/A

Additional information and things you've tried: Adding "temperature_unit": "C" to the discovery message fixes the problem. I will work on a PR to add a configuration variable to the Climate Core visual: section (similar to temperature_step:), which seems to be the proper way to handle this. Please let me know if there is some better approach.

probot-esphome[bot] commented 3 years ago

climate source climate issues climate recent changes (message by IssueLinks)

mtl010957 commented 3 years ago

Digging a bit deeper, I find that all temperature units are converted internally to Celsius, so I think the easy way to handle this is to just send "temp_unit:" "C" in the discovery message always, there is no need to expose it to allow any other value. I will submit a PR.