emsesp / EMS-ESP32

ESP32 firmware to read and control EMS and Heatronic compatible equipment such as boilers, thermostats, solar modules, and heat pumps
https://emsesp.github.io/docs
GNU Lesser General Public License v3.0
584 stars 100 forks source link

MQTT HomeAssistant relay control #1035

Closed aarturoo closed 1 year ago

aarturoo commented 1 year ago

I bought an EMS module from you and connected a WemosD1 S32 and a relay module to it. I added all this to my smart home "HomeAssistant". Unfortunately, I don't see any possibility for mqtt to add control of this relay directly from "HomeAssistant".

configuration.yaml I add this:

mqtt: switch:

But isn't work.

Is it possible for me to be able to turn the relay on and off from within the smart home?

MichaelDvP commented 1 year ago

For connecting a relais, especially the dangerous D1-shields, read: https://bbqkees-electronics.nl/wiki/gateway/using-gateway-gpio.html

Switching a gpio depends on ems-esp-version. You have not added the support-info, so i guess actual:

With HA integration i can't help.

aarturoo commented 1 year ago
aarturoo commented 1 year ago

commented

For connecting a relais, especially the dangerous D1-shields, read: https://bbqkees-electronics.nl/wiki/gateway/using-gateway-gpio.html

Yes, I know. That's why I made my own shield with an optoisolator. In addition, the relay is to switch the voltage-free (signal) contact.

Switching a gpio depends on ems-esp-version. You have not added the support-info, so i guess actual:

  • add analog output, gpio 22, name piec1
  • use command ems-esp/analogsensor/piec1
  • or use ems-esp/analogsensor/setvalue with payload id:22 and value:on/off (or 1/0, true/false)

With HA integration i can't help.

I add analog output GPIO22, name relay.

I add configuration.yaml: mqtt: switch:

But it doesn't work.

The relay works for me only as I directly control it from the EMS side. Unfortunately with the home assistant after adding the above code and trying to control it, nothing happens.

I use ems-esp32s with firmware version 3.5:

{ "System Info": { "version": "3.5.0", "platform": "ESP32", "uptime": "000+09:15:24.751", "uptime (seconds)": 33324, "free mem": 116, "max alloc": 69, "free app": 7, "reset reason": "Power on reset / APP CPU reset by PRO CPU" }, "Network Info": { "network": "WiFi", "hostname": "ems-esp", "RSSI": -38, "IPv4 address": "192.168.88.19/255.255.255.0", "IPv4 gateway": "192.168.88.1", "IPv4 nameserver": "192.168.88.1", "static ip config": false, "enable IPv6": false, "low bandwidth": true, "disable sleep": false, "enable MDNS": true, "enable CORS": false, "AP provision mode": "disconnected", "AP security": "wpa2", "AP ssid": "ems-esp" }, "NTP Info": { "NTP status": "connected", "enabled": true, "server": "time.google.com", "tz label": "Europe/Warsaw" }, "OTA Info": { "enabled": true, "port": 8266 }, "MQTT Info": { "MQTT status": "connected", "MQTT publishes": 10792, "MQTT queued": 0, "MQTT publish fails": 0, "MQTT connects": 1, "enabled": true, "client id": "ems-esp", "keep alive": 60, "clean session": false, "entity format": 0, "base": "ems-esp", "discovery prefix": "homeassistant", "nested format": 1, "ha enabled": true, "mqtt qos": 0, "mqtt retain": false, "publish time heartbeat": 60, "publish time boiler": 10, "publish time thermostat": 10, "publish time solar": 10, "publish time mixer": 10, "publish time other": 10, "publish time sensor": 10, "publish single": false, "publish2command": false, "send response": false }, "Syslog Info": { "enabled": false }, "Sensor Info": { "temperature sensors": 0, "temperature sensor reads": 0, "temperature sensor fails": 2, "analog sensors": 1, "analog sensor reads": 0, "analog sensor fails": 0 }, "API Info": { "API calls": 0, "API fails": 0 }, "Bus Info": { "bus status": "connected", "bus protocol": "HT3", "bus telegrams received (rx)": 23563, "bus reads (tx)": 2289, "bus writes (tx)": 0, "bus incomplete telegrams": 0, "bus reads failed": 0, "bus writes failed": 0, "bus rx line quality": 100, "bus tx line quality": 100 }, "Settings": { "board profile": "CUSTOM", "locale": "pl", "tx mode": 1, "ems bus id": 11, "shower timer": false, "shower alert": false, "phy type": 0, "rx gpio": 23, "tx gpio": 5, "dallas gpio": 18, "pbutton gpio": 0, "led gpio": 0, "hide led": false, "notoken api": false, "readonly mode": false, "fahrenheit": false, "dallas parasite": false, "bool format": 1, "bool dashboard": 1, "enum format": 1, "analog enabled": true, "telnet enabled": true, "max web log buffer": 50, "web log buffer": 50 }, "Devices": [ { "type": "boiler", "name": "Logamax Plus GB122/Condense 2300", "device id": "0x08", "product id": 234, "version": "05.05", "entities": 61, "handlers received": "0xBF 0xC2 0x15 0xD1 0xE3 0xE4 0xE5 0xE9", "handlers fetched": "0x14 0xE6 0xEA", "handlers pending": "0x10 0x11 0x1C 0x18 0x19 0x1A 0x35 0x16 0x33 0x34 0x26 0x2A", "handlers ignored": "0xC4 0x0DAC" } ] } .

MichaelDvP commented 1 year ago

Thx for the support info, you have ha-discovery enabled, so we need to fix this discovery to set the command topic right. The command topic should be ems-esp/analogsensor/relais The state-topic ems-esp/analogsensor and the val_tpl {{value_json['22'].value}} for the nested mqtt (your setting) or for single: {{value_json['relais']}}

MichaelDvP commented 1 year ago

Please check if discovery in https://github.com/MichaelDvP/EMS-ESP32/releases/tag/latest works. (I can not test, i don't use HA).