Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MQTT HomeAssistant relay control #1035

Closed
aarturoo opened this issue Feb 16, 2023 · 5 comments
Closed

MQTT HomeAssistant relay control #1035

aarturoo opened this issue Feb 16, 2023 · 5 comments
Labels
enhancement New feature or request
Milestone

Comments

@aarturoo
Copy link

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:
- name: "Piec1"
state_topic: "ems-esp/analogsensor_22"
command_topic: "ems-esp/analogsensor_22/set"
payload_on: "1"
payload_off: "0"

But isn't work.

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

@aarturoo aarturoo added the enhancement New feature or request label Feb 16, 2023
@MichaelDvP
Copy link
Contributor

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:

  • 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.

@aarturoo
Copy link
Author

@aarturoo aarturoo reopened this Feb 16, 2023
@aarturoo
Copy link
Author

aarturoo commented Feb 16, 2023

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:
- name: "Piec1"
state_topic: "ems-esp/analogsensor/relay"
command_topic: "ems-esp/analogsensor/relay/command"
payload_on: "ON"
payload_off: "OFF"

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
Copy link
Contributor

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 added a commit to MichaelDvP/EMS-ESP32 that referenced this issue Feb 17, 2023
@MichaelDvP
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants