Trying to use the relay control on a Shelly EM
I can control the relay from mqtt explorer, but not from the lovelace >developer tools>mqtt
mqtt explorer is ok with
shellies/sellyem-109664/relay/0 ( payload either 1 or 0 )
I’ve tried with and without a leading forward slash “/”
in my configuration.yaml I have
- platform: mqtt
name: Immersion load
state_topic: "/shellies/shellyem-109664/relay/0"
command_topic: "/shellies/shellyem-109664/relay/0"
payload_on: "1"
payload_off: "0"
on the config checker it thrown out with
Error loading /home/odroid/.homeassistant/configuration.yaml: while parsing a block mapping
in "/home/odroid/.homeassistant/configuration.yaml", line 1, column 1
expected <block end>, but found '<block sequence start>'
in "/home/odroid/.homeassistant/configuration.yaml", line 236, column 2
I’m confused over line 1 as no changes there, but it seems to want to have 2 spaces leading
homeassistant:
# Name of the location where Home Assistant is running
name: Home
# Location required to calculate the time the sun rises and sets
latitude: 52.66202
longitude: -2.46976
If I hash out the mqqt section above its happy with no leading spaces
Version reported in lovlace is 0.104.3 but I have updated but doesn’t show on lovelace.
The version showing doesn’t stop anything working so I left it as is
What I’m doing with the relay is to control a relay which shorts out a series diode ( 75A,1200v)
which is in series with the immersion element , normally a 3KW load, but with the series diode the load is 1.5KW. Used on my solarPV system so power generated is less than 3KW I can switch the load level, works fine on a resistive load.
what am I screwing up with the config please
Sorry
I did my normal trick with a space in the wrong place
The scripts , config and automation are checking OK BUT not talking to the EM relay, it reads OK from the sensors.
configuration.yaml:-
# from sensor section
- platform: mqtt
name: "Solar Energy"
state_topic: "shellies/shellyem-109664/emeter/0/energy"
value_template: "{{ value|float / 60000 }}" # Fix for Watt-minutes
qos: 1
unit_of_measurement: "kWh"
# icon: mdi:chart-bar
- platform: mqtt
name: "Solar Power"
state_topic: "shellies/shellyem-109664/emeter/0/power"
qos: 1
unit_of_measurement: "W"
#from switch section
- platform: mqtt
name: Immersion load
state_topic: "/shellies/shellyem-109664/relay/0"
command_topic: "/shellies/shellyem-109664/relay/0"
payload_on: "ON"
payload_off: "OFF"
A bit more
after restarting a few times I can control from dev tools>mqtt
and the following in configuration now seems OK
- platform: mqtt
name: Immersion load
state_topic: "shellies/shellyem-109664/relay/0"
command_topic: "shellies/shellyem-109664/relay/0"
payload_on: "on"
payload_off: "off"
BUT, I added a switch to lovelace so I can toggle switch.immersion_load
which sorta work
and watching mqtt explorer I can see the relay changing for on to off and viceversa
HOWEVER, if I turn it on, it turns off all by itself within 10 seconds, mqtt explorer shows the same.
If I set the payload to “on” from dev tools>mqtt it turns off after 15 seconds
I checked on the Shelly GUI for the EM, http , and the switch was set to OFF
So I set the set from the gui to ON
turned the switch off from dev tools>mqtt , and within 20 seconds the damn thing turns back on
The the moment the manual control switch on the shelly GUI for the EM takes priority .
After a lot more playing
/relay/1 can be set and unset without problems and it stays in the position set.
However it does not control the actual relay.
Two possibilities:
- Shelly fix their software , I’ve upgraded to the latest and it still behaves the same.
- Investigate whether the IC which has control of relay/0 also has a physical output
for /relay/1.
If it has modify the drive to what is probably a mosfet switching the relay so it is OR’d with a pair of diodes, so the output which is logic high has control.
In the mean time I’ll use a spare shelly1 to switch my external relay
I found what Shelly have done by routing through the API and playing with some http commands.
You no longer switch the relay , you have to switch the command to the relay
Shelly have not updated their documentation to indicate this, its applicable to the EM, Shelly1 and I suspect everything else that is switchable with the latest firmware.
- platform: mqtt
name: Shelly EM
state_topic: "shellies/shellyem-xxxxxx/relay/0"
command_topic: "shellies/shellyem-xxxxxx/relay/0/command"
payload_on: "on"
payload_off: "off"
- platform: mqtt
name: Shelly1
state_topic: "shellies/shelly1-xxxxxx/relay/0"
command_topic: "shellies/shelly1-xxxxxx/relay/0/command"
payload_on: "on"
payload_off: "off"