I have been using mine for a year and haven’t seen any behaviour like this. They have occasionally (about once or twice a month) failed to turn on, but I’m sure that is just radio signal interference. Have you complained to Energenie?
Cheers, that does sound like I was unlucky. I gave them two days, and they just kept doing it.
Combined with their need to be internet connected (a deal-breaker for me), I just stopped using them.
The Wemos work without the net, so my automations aren’t interrupted or broken by periodic internet disconnects.
As I said earlier in the thread, I use a Pimote and my own software, just to avoid this.
Ok, so I’ve just done a little bit more research and it appears there’s no python library available for accessing the internet API. The one that’s on github is for if you have the Pi boards.
As a first step forward we need to get a python library that’s capable of retrieving/modifying the MiHome state using the public API.
I had some problems with my hub not working but think it was all down to a faulty power supply and its now up and running. Would really appreciate any examples of how to use the api. I have had a go and im able to turn on devices using the command line on my pi but havent had much luck with the home assistant command line component. Thanks in advance.
Apologies for not getting back sooner, had some bug for over a week.
Anyway in the short term the easiest way I got things to work was by adding a command line switches and sensors. A more complicated example would be to add the following to your configuration.yaml.
switch:
platform: command_line
switches:
4_gang_extension:
command_on: 'curl -u "<YOURUSERNAME>:<YOURPASSWORD>" -X POST -H "Content-Type: application/json" -d "{\"id\":54321}" https://mihome4u.co.uk/api/v1/subdevices/power_on'
command_off: 'curl -u "<YOURUSERNAME>:<YOURPASSWORD>" -X POST -H "Content-Type: application/json" -d "{\"id\":54321}" https://mihome4u.co.uk/api/v1/subdevices/power_off'
friendly_name: TV Extension
4_gang_extension_a:
command_on: 'curl -u "<YOURUSERNAME>:<YOURPASSWORD>" -X POST -H "Content-Type: application/json" -d "{\"id\":54321,\"socket\":0}" https://mihome4u.co.uk/api/v1/subdevices/power_on'
command_off: 'curl -u "<YOURUSERNAME>:<YOURPASSWORD>" -X POST -H "Content-Type: application/json" -d "{\"id\":54321,\"socket\":0}" https://mihome4u.co.uk/api/v1/subdevices/power_off'
friendly_name: Living Room Lamp
4_gang_extension_b:
command_on: 'curl -u "<YOURUSERNAME>:<YOURPASSWORD>" -X POST -H "Content-Type: application/json" -d "{\"id\":54321,\"socket\":1}" https://mihome4u.co.uk/api/v1/subdevices/power_on'
command_off: 'curl -u "<YOURUSERNAME>:<YOURPASSWORD>" -X POST -H "Content-Type: application/json" -d "{\"id\":54321,\"socket\":1}" https://mihome4u.co.uk/api/v1/subdevices/power_off'
friendly_name: TV
4_gang_extension_c:
command_on: 'curl -u "<YOURUSERNAME>:<YOURPASSWORD>" -X POST -H "Content-Type: application/json" -d "{\"id\":54321,\"socket\":2}" https://mihome4u.co.uk/api/v1/subdevices/power_on'
command_off: 'curl -u "<YOURUSERNAME>:<YOURPASSWORD>" -X POST -H "Content-Type: application/json" -d "{\"id\":54321,\"socket\":2}" https://mihome4u.co.uk/api/v1/subdevices/power_off'
friendly_name: FireTV Stick
4_gang_extension_d:
command_on: 'curl -u "<YOURUSERNAME>:<YOURPASSWORD>" -X POST -H "Content-Type: application/json" -d "{\"id\":54321,\"socket\":3}" https://mihome4u.co.uk/api/v1/subdevices/power_on'
command_off: 'curl -u "<YOURUSERNAME>:<YOURPASSWORD>" -X POST -H "Content-Type: application/json" -d "{\"id\":54321,\"socket\":3}" https://mihome4u.co.uk/api/v1/subdevices/power_off'
friendly_name: Audio Splitter
You just need to change <YOURUSERNAME>
and <YOURPASSWORD>
to whatever you use to login to the mihome4u website. You also need to change the id, in my example 54321 to your device ID. The easiest way to get this is to login to the mihome4u website and click on the manage link for the device you want to use in Home Assistant. The look at the url and you want the number just before “/edit”, so in my example my url would be:
https://mihome4u.co.uk/devices/4409/subdevices/54321/edit
This above example is for a 4 gang extension so what is does is send on and off states for each socket and one to turn all sockets on/off.
If you are only controlling a single socket it would be something like this:
switch:
platform: command_line
switches:
dining_lamp:
command_on: 'curl -u "<YOURUSERNAME>:<YOURPASSWORD>" -X POST -H "Content-Type: application/json" -d "{\"id\":54321}" https://mihome4u.co.uk/api/v1/subdevices/power_on'
command_off: 'curl -u "<YOURUSERNAME>:<YOURPASSWORD>" -X POST -H "Content-Type: application/json" -d "{\"id\":54321}" https://mihome4u.co.uk/api/v1/subdevices/power_off'
friendly_name: Dining Lamp
To pull current usage data from a mi|Home Adapter Plus socket I do it like this:
sensor:
platform: command_line
command: 'curl -u "<YOURUSERNAME>:<YOURPASSWORD>" -X POST -H "Content-Type: application/json" -d "{\"id\":12345}" https://mihome4u.co.uk/api/v1/subdevices/show'
name: Washer
unit_of_measurement: w
value_template: '{{ value_json.data.last_data_instant }}'
Hope all that makes sense, once you’ve done a couple it’s actually quite easy and works well. Ultimately it would be better to have a proper Python component like @curtisjk mentioned but this is easy for now.
Hi Steve. Thank you so much for the examples. I had tried something similar but couldnt get the format quite right. Really appreciate the help.
Hi @Midgey just a note, the Energenie hardware is controlled via 433Mhz and can be controlled via the new RFLink component directly, without the MiHome hub.
I have emailed RFLink gateway team to have the wall switch added to their supported hardware. The basic plug in sockets are already supported. They are recognized as “Eurodomest” sockets.
Thank you for the info!
Many thanks to @stevenhorner ; I was finally able to get my Mi|Home switches working thanks to his example.
does anyone have multiple single switches setup from energenie… i can get them to work, but when i set any automation to switch one off they all turn off… help would be appreciated…
I’m surprised that still no-one seems to have made a component to use Energenie via the web API, since it seems to be quite a popular platform. So I thought I’d have a go myself!
It’s still very much work in (slow) progress, but I’ve got some basic functionality, so I thought I’d share, and see if anyone wants to try it out or help to get it working sooner. Currently it works with non-monitor switches, and I’m working on a sensor platform.
A library to call the API via python can be found here:
and my HA fork is here: https://github.com/ng110/home-assistant
Enjoy.
I’ve got several Mi|Home plugs around the house and also sockets, so whilst in principal I’m happy to help testing they are a key component to my working setup and I wouldn’t want to lose that! Is is easy to swap between testing components and live working components?
How can i use this in my own installation?
Currently have the on/off working but would be great to get the toggle working correctly. (cannot get the state to correctly show as is).
Many thanks
There are lots of things not working yet. It’s work-in-progress as mentioned (and I’m not getting much time to work on it). But if you have the on/off working, it sounds you’ve already got it set up okay? Note that the non-monitor Energenie switches do not report back their state, so the state is assumed, and will never be 100% reliable (especially since Energenie switches sometimes fail to switch when requested, or switch off when not requested).
Cheers, N.
I could not figure out how to set up your python script so currently just have command line switch calling the API by ID.
I have set binary sensors to check state using api (these work) but would like the switches to correctly check status also and then show the toggle in front end instead of separate buttons.
(These are the blue sockets and a light switch connected via Mi|Home gateway)
Hi Steve
I don’t suppose you could share the setup could you for the command line sensor as I am struggling with this to get data back from ETRV valves
Thanks in advance
Paul
Hello,
I don’t have any of their TRVs, have looked at them for ages but not sure how well they would fit with my setup. What have you tried so far, the format for the Command Line Sensor I used was further up in the thread but copied below:
sensor:
platform: command_line
command: 'curl -u "<YOURUSERNAME>:<YOURPASSWORD>" -X POST -H "Content-Type: application/json" -d "{\"id\":12345}" https://mihome4u.co.uk/api/v1/subdevices/show'
name: Washer
unit_of_measurement: w
value_template: '{{ value_json.data.last_data_instant }}'
I haven’t changed it since I posted it but it still works. I will help if I can.
Hi Steve
Thanks for your quick response and your posting as it was mot helpful
I had the commands for the light switches and I used your config to do the same with the ertv’s
Just setting up the data as we speak on HA
Many thanks again
Paul
Hi Steve
All working good so far
However if I wanted to set the Target Temperature via an Automation would you be able to tell me or guide me how to set this
The APi Says
/api/v1/subdevices/set_target_temperature
Paul