JeffSteinbok / hass-dreo

Dreo Smart Device Integration for Home Assistant
MIT License
122 stars 35 forks source link

Temperature sensor #20

Closed miggi92 closed 1 year ago

miggi92 commented 1 year ago

It would be nice if the temperature isn't a attribute of the fan but an separate entity. And the temperature unit is fahrenheit would be nice if the unit is the same as the default unit of the system. Would be nice if it can be similar to this example: Screenshot_20230714-113240~2.png

JeffSteinbok commented 1 year ago

I have it on my list to eventually get to. In the meantime, you can do it yourself with a template sensor:

  - platform: template
    sensors:
      main_bedroom_fan_temperature:
        friendly_name: "Main Bedroom Fan Temperature"
        value_template: "{{ state_attr('fan.main_bedroom_fan', 'temperature') }}"
        unit_of_measurement: '°F'
        icon_template: "{{'mdi:thermometer'}}"  
JeffSteinbok commented 1 year ago

I have this working in a temp branch.

JeffSteinbok commented 1 year ago

This is completed in the latest beta release. https://github.com/JeffSteinbok/hass-dreo/releases/tag/v0.4.0b1

JeffSteinbok commented 1 year ago

@miggi92 - I'm trying to see how the API reports temperature outside the USA. Can you send me diagnostics? Curious if it reports celcius from the API or always F?

miggi92 commented 1 year ago

@JeffSteinbok yes sure.

{
  "home_assistant": {
    "installation_type": "Home Assistant OS",
    "version": "2023.7.3",
    "dev": false,
    "hassio": true,
    "virtualenv": false,
    "python_version": "3.11.4",
    "docker": true,
    "arch": "aarch64",
    "timezone": "Europe/Berlin",
    "os_name": "Linux",
    "os_version": "6.1.21-v8",
    "supervisor": "2023.07.1",
    "host_os": "Home Assistant OS 10.3",
    "docker_version": "23.0.6",
    "chassis": "embedded",
    "run_as_root": true
  },
  "custom_components": {
    "var": {
      "version": "0.15.0",
      "requirements": []
    },
    "dreo": {
      "version": "0.0.2",
      "requirements": [
        "websockets"
      ]
    },
    "hacs": {
      "version": "1.32.1",
      "requirements": [
        "aiogithubapi>=22.10.1"
      ]
    }
  },
  "integration_manifest": {
    "domain": "dreo",
    "name": "Dreo",
    "codeowners": [
      "@jeffsteinbok"
    ],
    "config_flow": true,
    "dependencies": [],
    "documentation": "https://github.com/jeffsteinbok/hass-dreo/blob/master/README.md",
    "iot_class": "cloud_push",
    "issue_tracker": "https://github.com/jeffsteinbok/hass-dreo/issues",
    "loggers": [
      "dreo",
      "pydreo"
    ],
    "requirements": [
      "websockets"
    ],
    "version": "0.0.2",
    "is_built_in": false
  },
  "data": {
    "dreo": {
      "fan_count": 1,
      "raw_devicelist": {
        "code": 0,
        "msg": "OK",
        "data": {
          "currentPage": 1,
          "pageSize": 100,
          "totalNum": 1,
          "totalPage": 1,
          "list": [
            {
              "deviceId": "1679771991586451458",
              "sn": "XXX",
              "brand": "Dreo",
              "model": "DR-HTF002S",
              "productId": "1401783383044132867",
              "productName": "Tower Fan",
              "deviceName": "Tower Fan",
              "shared": false,
              "series": null,
              "seriesName": "Cruiser Pro T2 S",
              "controlsConf": {
                "template": "DR-HTF002S",
                "lottie": {
                  "key": "poweron",
                  "frames": [
                    {
                      "value": 0,
                      "frame": [
                        0
                      ]
                    },
                    {
                      "value": 1,
                      "frame": [
                        2
                      ]
                    }
                  ]
                },
                "cards": [
                  {
                    "type": 2,
                    "title": "device_control_temp",
                    "icon": "",
                    "image": "",
                    "url": "",
                    "show": true
                  },
                  {
                    "type": 6,
                    "title": "device_settings_title",
                    "icon": "ic_setting",
                    "image": "",
                    "url": "dreo://nav/device/setting?deviceSn=${sn}",
                    "show": true,
                    "key": "setting"
                  }
                ],
                "preference": [
                  {
                    "id": "200",
                    "type": "Panel Sound",
                    "title": "device_control_panelsound",
                    "image": "ic_mute",
                    "reverse": false,
                    "cmd": "voiceon"
                  },
                  {
                    "id": "210",
                    "type": "Display Auto Off",
                    "title": "device_fans_mode_auto_display",
                    "image": "ic_display",
                    "reverse": true,
                    "cmd": "ledalwayson"
                  },
                  {
                    "id": "230",
                    "type": "Temperature Unit",
                    "title": "device_control_temp_unit",
                    "image": "ic_temp_unit"
                  }
                ],
                "control": [
                  {
                    "id": "100",
                    "type": "Mode",
                    "title": "device_mode",
                    "items": [
                      {
                        "text": "device_fans_mode_straight",
                        "textColors": [
                          "#D5D6D7",
                          "#D5D6D7"
                        ],
                        "image": "ic_normal_wind",
                        "imageColors": [
                          "#D5D6D7",
                          "#25D7E4"
                        ],
                        "cmd": "windtype",
                        "value": 1
                      },
                      {
                        "text": "device_fans_mode_natural",
                        "textColors": [
                          "#D5D6D7",
                          "#D5D6D7"
                        ],
                        "image": "ic_natural_wind",
                        "imageColors": [
                          "#D5D6D7",
                          "#2CDD96"
                        ],
                        "cmd": "windtype",
                        "value": 2
                      },
                      {
                        "text": "device_control_mode_sleep",
                        "textColors": [
                          "#D5D6D7",
                          "#D5D6D7"
                        ],
                        "image": "ic_sleep_wind",
                        "imageColors": [
                          "#D5D6D7",
                          "#6249DF"
                        ],
                        "cmd": "windtype",
                        "value": 3
                      },
                      {
                        "text": "device_control_mode_auto",
                        "textColors": [
                          "#D5D6D7",
                          "#D5D6D7"
                        ],
                        "image": "ic_auto_wind",
                        "imageColors": [
                          "#D5D6D7",
                          "#0A80F5"
                        ],
                        "cmd": "windtype",
                        "value": 4
                      }
                    ]
                  },
                  {
                    "id": "110",
                    "type": "Speed",
                    "title": "device_control_speed",
                    "items": [
                      {
                        "text": "1",
                        "cmd": "windlevel",
                        "value": 1
                      },
                      {
                        "text": "6",
                        "cmd": "windlevel",
                        "value": 6
                      }
                    ]
                  },
                  {
                    "id": "120",
                    "type": "Oscillation",
                    "title": "device_control_oscillation",
                    "items": [],
                    "cmd": "shakehorizon"
                  }
                ],
                "category": "Tower Fan",
                "setting": [
                  {
                    "text": "Firmware Version",
                    "image": "image.png",
                    "value": "1.0.0",
                    "url": "dreo://control"
                  }
                ]
              },
              "mainConf": {
                "isSmart": true,
                "isWifi": true,
                "isBluetooth": true,
                "isVoiceControl": true
              },
              "resourcesConf": {
                "imageSmallSrc": "https://resources-eu.dreo-cloud.com/app/202212/27a0958a496e54efb8c5b42989b2014ac.png",
                "imageFullSrc": "https://resources-eu.dreo-cloud.com/app/202212/2c6bf9392a15c472e92d8d6e3be9364eb.zip"
              },
              "servicesConf": [
                {
                  "key": "user_manual",
                  "value": "https://resources-eu.dreo-cloud.com/app/202301/11e32a44abb39d4ad8a27012ae3bfa1448.pdf"
                }
              ]
            }
          ]
        }
      }
    },
    "devices": {
      "fans": [
        {
          "_name": "Tower Fan",
          "_device_id": "1679771991586451458",
          "_sn": "**REDACTED**",
          "_model": "DR-HTF002S",
          "_dreo": {
            "__type": "<class 'custom_components.dreo.pydreo.PyDreo'>",
            "repr": "<custom_components.dreo.pydreo.PyDreo object at 0x7f0748ab50>"
          },
          "_is_on": false,
          "raw_state": {
            "code": 0,
            "msg": "OK",
            "data": {
              "mixed": {
                "mcu_hardware_model": {
                  "state": "CMS89F7518/EUR",
                  "timestamp": 1689681750
                },
                "wifi_ssid": "**REDACTED**",
                "windlevel": {
                  "state": 2,
                  "timestamp": 1690327682
                },
                "wifi_rssi": {
                  "state": -37,
                  "timestamp": 1690327682
                },
                "poweron": {
                  "state": false,
                  "timestamp": 1690327682
                },
                "windtype": {
                  "state": 4,
                  "timestamp": 1690327682
                },
                "tempunit": {
                  "state": 2,
                  "timestamp": 1690327682
                },
                "timeron": {
                  "state": {
                    "du": 0,
                    "ts": 1689681750
                  },
                  "timestamp": null
                },
                "voiceon": {
                  "state": true,
                  "timestamp": 1690327682
                },
                "wrong": {
                  "state": 0,
                  "timestamp": 1690327682
                },
                "module_firmware_version": {
                  "state": "1.2.24",
                  "timestamp": 1690327682
                },
                "mcuon": {
                  "state": true,
                  "timestamp": 1689681750
                },
                "connected": {
                  "state": true,
                  "timestamp": 1690327682
                },
                "timeroff": {
                  "state": {
                    "du": 0,
                    "ts": 1689681750
                  },
                  "timestamp": null
                },
                "shakehorizon": {
                  "state": true,
                  "timestamp": 1690327682
                },
                "network_latency": {
                  "state": 80,
                  "timestamp": 1690327682
                },
                "module_hardware_model": {
                  "state": "PAI-051",
                  "timestamp": 1690327682
                },
                "mcu_firmware_version": {
                  "state": "2.0.6",
                  "timestamp": 1689681750
                },
                "temperature": {
                  "state": 79,
                  "timestamp": 1690327682
                },
                "module_hardware_mac": "**REDACTED**",
                "ledalwayson": {
                  "state": false,
                  "timestamp": 1690327682
                }
              },
              "sn": "**REDACTED**",
              "productId": "1401783383044132867",
              "region": "eu-central-1"
            }
          },
          "_attr_cbs": [
            {
              "__type": "<class 'function'>",
              "repr": "<function DreoFanHA.async_added_to_hass.<locals>.update_state at 0x7ee0e45440>"
            }
          ],
          "_lock": {
            "__type": "<class '_thread.lock'>",
            "repr": "<unlocked _thread.lock object at 0x7ee0fca200>"
          },
          "_fan_definition": {
            "__type": "<class 'custom_components.dreo.pydreo.models.DreoFanDetails'>",
            "repr": "DreoFanDetails(preset_modes=['normal', 'natural', 'sleep', 'auto'], speed_range=(1, 6))"
          },
          "_windType": 4,
          "_oscillating": true,
          "_fan_speed": 2,
          "_temperature": 79
        }
      ]
    }
  }
}
miggi92 commented 1 year ago

I installed the beta. The temperature sensor displays the temperature in Celcius.

image
JeffSteinbok commented 1 year ago

Excellent - Is working as expected. I'm auto-detecting units from the value. It's a hack, but should work 99.9% of the time.