Sign inSign up

podpalch/ha-devi-mqtt

By podpalch

•Updated 9 months ago

Home Assistant MQTT bridge for DeviReg Smart devices

Image
Integration & delivery
Internet of things
0

3.7K

podpalch/ha-devi-mqtt repository overview

⁠Home Assistant MQTT Danfoss Binding

Weekly Schedule UI

This is Home Assistant service for DeviReg Smart thermostats. Main idea behind - integration with Home Assistant via MQTT by auto discovery (not as HA addon or HACS integration). Around 50 sensors are implemented and can be used in Home Assistant.

⁠Supported Things

  • DeviReg(tm) Smart floor thermostat (supported, tested https://www.devismart.com/⁠)
  • Danfoss Icon controller (unsupported, requires real device to implement)
  • Danfoss Icon room (unsupported, requires real device to implement)

If you have Icon device and know Java a little bit - you can fork and implement it by yourself.

⁠Installation and supported architectures

Relies on OpenSDG library (https://github.com/Sonic-Amiga/opensdg/releases⁠) for communicating with the hardware. The final JAR includes all dependencies compiled in and is ready to use without installing any other dependencies. Tested on Linux, MacOS, but should work fine on Windows as well. Docker image is also available.

⁠Discovery

Discovery of configuration is required step to use the software. Thermostat is using cloud security and requires setup/pairing by OTP code entry. As it's required user input, it can't be done in Docker.

To pair the software with the thermostat, you need mobile application paired with the thermostat. In mobile application, you have to go to Settings -> Share house -> Generate OTP.

Steps:

  1. Run the discovery tool, follow the instructions from app.
java -cp ha-devi-mqtt.jar io.homeassistant.devi.mqtt.service.DiscoveryService
  1. Launch mobile application, enter username and OTP code (it might be required to enter OTP more then once, due to bug in library).
  2. The configuration file will be generated (devi_config.json).
  3. Keep the configuration file in secure place, it contains private key required to control your device.

⁠Runtime

Two options how to start is available.

  1. Plain Java
java -cp target/ha-devi-mqtt.jar io.homeassistant.devi.mqtt.service.ConsoleRunner --auto-discovery-templates auto-discovery-templates --mqtt-config mqtt_config.json --devi-config devi_config.json
  1. Docker (linux/amd64, linux/arm64/v8 - Mac M1)
docker run -it --rm -v $(pwd)/devi_config.json:/app/config/devi_config.json -v $(pwd)/mqtt_config.json:/app/config/mqtt_config.json -v $(pwd)/auto-discovery-templates:/app/config/auto-discovery-templates  podpalch/ha-devi-mqtt

⁠Configuration

⁠devi_config.json (this file is generated by discovery tool)
{
  "peerId": "Peer ID, also known as Public key. All devices on the Grid are identified by these keys",
  "privateKey": "hex coded private key",
  "houseName": "name of the house (not used anywhere in code)",
  "rooms": [
    {
      "serialNumber": "(int) serial number (used to build MQTT topic path)",
      "devicePeerID": "peer id of the thermostat",
      "name": "name of the room (not used anywhere in code, device is bound to room)"
    }
  ],
  "userName": "unique username, that was entered during the pairing"
}
⁠mqtt_config.json
{
  "host": "IP or hostname of the MQTT broker",
  "port": "1883",
  "user": "mqtt-user",
  "password": "mqtt-password"
}

⁠Schedule editing component

I've built simple lovelace Card to edit weekly schedule for this thermostat. It's available here: https://github.com/igor-podpalchenko/ha-weekly-schedule-card⁠

type: custom:weekly-schedule-card
entity: sensor.devi_sensor_week_schedule_0
devMode: false
encodingSchema: Devi
commandTopic: devi/command/10159384/sensor_week_schedule

⁠Climate lovelace card

  • Mode: used only to display state. Off / Heat - corresponds to relay state.
  • Presets: displays current mode, option "SET OVERRIDE" is used to switch to OVERRIDE mode (Temporary Setpoint is used to set target temperature).
  • Temperature slider: used to set target temperature (Temporary Setpoint).

Note: thermostat has a plenty of modes, every mode has it's own temperature setpoint. Override mode sets temperature till the end of the day, after that thermostat will switch to previous mode.

⁠Auto-discovery-templates folder

This folder contains templates for auto-discovery of the devices in Home Assistant. The templates are in JSON format and are used by the discovery service to create the entities. You should copy this folder to your installation.

${deviceSN} - will be replaced with device serial number ${deviceNumber} - will be replaced with device number (if more than one device is used at home)

⁠binary_sensor_heating_state.json
{
    "topic": "homeassistant/binary_sensor/${deviceSN}_binary_sensor_heating_state/config",
    "template": {
        "state_topic": "devi/state/${deviceSN}/binary_sensor_heating_state",
        "device": {
            "identifiers": [
                "${deviceSN}"
            ],
            "manufacturer": "Danfoss",
            "name": "DeviReg ${deviceSN}",
            "model": "DeviReg Smart Thermostat"
        },
        "unique_id": "${deviceSN}_binary_sensor_heating_state",
        "object_id": "devi_binary_sensor_heating_state_${deviceNumber}",
        "name": "Sensor heating state",
        "device_class": "heat"
    }
}
⁠Available Sensors
channeltypedescriptionRead-only
binary_sensor_cloud_connectedBinary SensorCloud connection statusY
binary_sensor_heating_stateBinary SensorCurrent heating stateY
binary_sensor_warning_breakoutBinary SensorWarning for breakout conditionY
binary_sensor_warning_disconnectedBinary SensorWarning for disconnected conditionY
binary_sensor_warning_overheatBinary SensorWarning for overheatingY
binary_sensor_warning_shortedBinary SensorWarning for short circuitY
binary_sensor_warning_unrecoverableBinary SensorWarning for unrecoverable errorY
binary_sensor_window_openBinary SensorWhether an open window is detected in the roomY
number_brightnessNumberThermostat screen brightness, from 0 to 100N
on_time_30_daysTime (s)Summary heater on time for the last 30 daysY
on_time_7_daysTime (s)Summary heater on time for the last 7 daysY
on_time_totalTime (s)Total heater on timeY
on_time_30_days_kwhEnergyEnergy consumption in kWh for the last 30 daysY
on_time_7_days_kwhEnergyEnergy consumption in kWh for the last 7 daysY
on_time_total_kwhEnergyTotal energy consumption in kWhY
sensor_active_setpointStringActive setpoint being usedY
sensor_control_stateStringCurrent control state: "CONFIGURING", "MANUAL", "HOME", "AWAY", "VACATION", "FATAL", "PAUSE", "OFF","OVERRIDE"Y
select_control_modeStringCurrent control mode: "CONFIGURING", "MANUAL", "HOME", "AWAY", "VACATION", "FATAL", "PAUSE", "OFF","OVERRIDE", "AWAY", "HOME"N
sensor_week_scheduleJSONWeekly schedule in JSON format in Devi time range formatN
setpoint_antifreezeTemperatureSet point for antifreeze modeN
setpoint_awayTemperatureSet point for away modeN
setpoint_comfortTemperatureSet point for comfort modeN
setpoint_economyTemperatureSet point for economy modeN
setpoint_manualTemperatureSet point for manual modeN
setpoint_max_floorTemperatureMaximum allowed floor temperatureN
setpoint_min_floorTemperatureMinimum allowed floor temperatureN
setpoint_temporaryTemperatureTemporary set pointN
setpoint_warningTemperatureTemperature below which an alarm is sentN
switch_forecastSwitchEnable or disable forecast heatingN
switch_min_floor_enableSwitchEnable keeping minimum floor temperatureN
switch_screen_lockSwitchEnable screen lockN
switch_window_detectionSwitchEnable open window detectionN
sys_firmware_versionStringFirmware version of the deviceY
sys_hardware_versionStringHardware version of the deviceY
sys_info_floor_typeStringFloor type informationY
sys_info_output_powerPowerOutput power of the deviceY
sys_info_sensor_typeStringType of sensor connectedY
sys_info_regulation_typeStringType of regulation being used by the systemY
sys_info_room_typeStringType of room where the system is installedY
sys_production_dateDateDevice production dateY
sys_relay_on_countNumberNumber of times the relay has been turned onY
sys_room_nameStringRoom name assigned to the deviceN
sys_run_timeTimeTotal runtime of the deviceY
sys_serial_numberStringSerial number of the deviceY
sys_wifi_connect_ssidStringSSID of the connected Wi-Fi networkY
sys_wifi_strengthNumberSignal strength of the Wi-Fi connectionY
sys_house_nameStringName of the house or locationY
sys_connection_countNumberNumber of connection attempts or successful connectionsY
temperature_floorTemperatureFloor temperature sensor readingY
temperature_roomTemperatureRoom temperature sensor readingY
⁠Default command topics
FileCommand Topic
number_setpoint_max_floor.jsondevi/command/${deviceSN}/setpoint_max_floor
number_setpoint_manual.jsondevi/command/${deviceSN}/setpoint_manual
number_setpoint_warning.jsondevi/command/${deviceSN}/setpoint_warning
number_setpoint_away.jsondevi/command/${deviceSN}/setpoint_away
number_setpoint_min_floor.jsondevi/command/${deviceSN}/setpoint_min_floor
number_setpoint_temporary.jsondevi/command/${deviceSN}/setpoint_temporary
number_setpoint_antifreeze.jsondevi/command/${deviceSN}/setpoint_antifreeze
number_setpoint_economy.jsondevi/command/${deviceSN}/setpoint_economy
number_setpoint_comfort.jsondevi/command/${deviceSN}/setpoint_comfort
switch_min_floor_enable.jsondevi/command/${deviceSN}/switch_min_floor_enable
switch_screen_lock.jsondevi/command/${deviceSN}/switch_screen_lock
switch_window_detection.jsondevi/command/${deviceSN}/switch_window_detection
switch_forecast.jsondevi/command/${deviceSN}/switch_forecast
select_control_mode.jsondevi/command/${deviceSN}/select_control_mode

Note: the pairing is performed with the home, not with the concrete device. If you have multiple devices, all devices will be paired with software.

Protocol is called SecureDeviceGrid(tm) (http://securedevicegrid.com/⁠).

Original source (https://github.com/Sonic-Amiga/org.openhab.binding.devireg⁠)

Tag summary

Content type

Image

Digest

sha256:e58d0e73b…

Size

69.3 MB

Last updated

9 months ago

docker pull podpalch/ha-devi-mqtt