Wonder if anyone can help me out, I have a number of Energenie Mi|Home switches and sockets and though I have managed to use the API to send the on/off commands I am struggling to get the current state … below is an example of my code;
It looks like the options for RF control from HASS on a Pi 3 (via venv) are a Pi-mote vs an RFLink arduino kit with pre-soldering from Nodo Shop. I have some questions please:
Using @gpbenton 's engMQTTClient, how do you find the IDs of the devices? Do the Energenie light switches have OpenThing IDs printed on them somewhere?
The energenie devices work on two different protocols. The switches and sockets are receive only and use a standard 433MHz protocol. These can be used with most 433MHz decode/encode diy kits, including RFLink and OpenMQTTGateway. This is not the OpenThings protocol.
Other Energenie devices are two way, such as the eTRVs and Energy Montoring devices. These use the OpenThings protocol and FSK modulation, and are not controllable with normal 433MHz controllers.
My engMQTTClient spends most of its time listening for OpenThings messages using FSK encoding, but switches to OOK when it receives an MQTT message to send a signal to a switch, so effectively works with both.
I do use some Sensoo light switches I got from AliExpress with the PiMote, but I was surprised they worked, and can make no guarantees about any other 433MHz devices. There are sublte differences about the way each of them works.
As explained above, the light switches are receive only and do not use OpenThings and so do not have an ID. The devices using Openthings broadcast periodically with their ID and this is received by engMQTTClient and sent over MQTT. The MQTT topic contains the OpenThings ID.
You program the light switches (I assume, I don’t have any Energenie Light Switches) like most 433MHz switches by holding down a button for a few seconds until an LED flashes, and then sending a signal to it from a remote (or PiMote).
Ah thanks, I didn’t know that. So if using a PiMote from software you can effectively just send ‘any code’ and as long as it’s the first code the switch receives it stores it? Is there a HASS UI for that? If not what tools do you use? How does programming work if there’s a lot of background 433mhz traffic in a city environment?
Do you send signals to those using engMQTTClient too?
The switch can store two different codes, so you can use two different remotes to control it. You can make up codes for use from the PiMote, but there are rules that have to be met in the signal. I think I found out what they were when I was writing engMQTTclient, but I have long since forgotten. I may have them written down in the documentation. I listen for the remote code and just use that.
I use OpenMQTTGateway to listen for signals, but any 433Mhz snooper should do the job.
Not directly, but if you configure a switch to send the code, it will be sent . when you turn the switch on.
I can’t help there, I live in a rural market town. But the signal strength is attenuated by walls, and there are plenty of codes, so I don’t think it would be a problem.
Yes, and I was surprised it worked. I just copied the code the the remote sent and used it in the MQTT message, but there is no guarantee it will work for anything else. There are different protocols used by different manufacturers, and not all of them are compatible.
Hi Steve you seem to be the go to man on the home assistant, energenie, command line subject and wondered if you could cast any light on my problem?
I have an energenie thermostat which i can switch on and off in home assistant with the code below
As you can see i have hashed out the command_state and value_template as these are not returning the state of the relay and make the switch return to off after it is switched on.
Any help appreciated
Apologies for not replying I haven’t done much with Energenie for a long time. I’m guessing you are trying to do a switch that turns on and off your thermostat which is the part that is uncommented.
I think the part that is commented should actually be a sensor not a switch.
Thanks for the response steve i had got a sensor setup already but it didnt work with the command_line switch, but it does work with the template switch with the following
I’ve been using the HTTP POST commands as posted by StevenHorner further up this thread (thanks!). However I’ve noticed that the switch on/off commands are no longer working in ny HA setup. I can still turn them off from the Energenie web console, and have re-checked my device ID’s against the Energenie console, but my Home Assistant commands are no longer triggering the switches.
Here’s an example of one of my commands (with id’s substituted):
Is it possible to get the current state of energenie switches such that the HA UI shows the correct state?
I’m pretty new to this but using the mihome api and the curl command as described above I have my light and plug switches working in that I can turn them on/off. (So thanks for the info) But, if the switch is triggered by something else, say I actually press the physical button, the HA UI becomes out of sync - even when refreshed. I know there is a api to get current state, but is it possible to integrate this into HA Ui some how?
Thanks
Thank you!
I accidentally bought one of these thinking it was tuya-based, and at least I can control it for the few weeks I need it and then can send it back when I can access my already tasmotised plugs.
I was using a APIRequest.io to get the details but it kept responding “not found” when controlling devices, but your command just worked as soon as I put in the details.
Sorry for the delay, I have not completed the full switch yet (will post once complete), but here is the code to get power measurement from the MiHome Smart Plug MIHO005 and MIHO004 and add them to the “Energy” page of home assistant. Using “rest” and “integration” platforms.
The platform: integration will show up in “/developer-tools/statistics” and can be added via “/config/energy”
Set username, password and payload ID (for your switch/sensor) as appropriate.
########################################################################
# MiHome Living Room TV Switch
########################################################################
# Control and Monitor.
# Mi|Home Smart Plug+ MIHO005
- platform: rest
name: "MiHome Living Room TV Switch Watts"
resource: 'https://mihome4u.co.uk/api/v1/subdevices/show'
method: POST
authentication: basic
username: !secret MiHome_ID
password: !secret MiHome_Password
payload: '{"id":311088}'
value_template: '{{ value_json.data.real_power }}'
unit_of_measurement: W
device_class: power #Power, watts. Not "Energy" i.e. Wh.
state_class: measurement
json_attributes_path: "data"
json_attributes:
- label
- device_id
- power_state
- startup_mode
- device_type
- remote_id
- voltage
- voltage_reported_at
- frequency
- real_power
- today_wh
headers:
Content-Type: application/json
force_update: true
# https://www.home-assistant.io/integrations/integration/
# https://community.home-assistant.io/t/powercalc-virtual-power-sensors/318515/3
# https://www.home-assistant.io/integrations/integration/#energy
- platform: integration
source: sensor.mihome_living_room_tv_switch_watts
name: MiHome Living Room TV Switch Energy
unit_prefix: k
unit_time: h
round: 2
unit: kWh
########################################################################
# MiHome Server Plug
########################################################################
# https://mihome4u.co.uk/devices/37815/subdevices/279158/edit
# Monitor only, has no control.
# Mi|Home Smart Monitor Plug MIHO004
- platform: rest
name: "MiHome Server Monitor Plug Watts"
resource: 'https://mihome4u.co.uk/api/v1/subdevices/show'
method: POST
authentication: basic
username: !secret MiHome_ID
password: !secret MiHome_Password
payload: '{"id":279158}'
value_template: '{{ value_json.data.real_power }}'
unit_of_measurement: W
device_class: power #Power, watts. Not "Energy" i.e. Wh.
state_class: measurement
json_attributes_path: "data"
json_attributes:
- label
- device_id
- power_state
- startup_mode
- device_type
- remote_id
- voltage
- voltage_reported_at
- frequency
- real_power
- today_wh
headers:
Content-Type: application/json
force_update: true
# https://www.home-assistant.io/integrations/integration/
# https://community.home-assistant.io/t/powercalc-virtual-power-sensors/318515/3
# https://www.home-assistant.io/integrations/integration/#energy
- platform: integration
source: sensor.mihome_server_monitor_plug_watts
name: MiHome Sever Monitor Plug Energy
unit_prefix: k
unit_time: h
round: 2
unit: kWh
Hi All very new to home assistant i have about 8eTRV and verious light switchs and sockets and they all connect the Energnie hub and for many years have work great. to start with all i want is to be simple be able to record the temperature in home assistant but i cant find a simple solution to follow. I am also using an old pc to power Home assistant.