EcoPlug integration

wow, that was fast! thank you! I had already downgraded to have the functionality back, but it looks like I’ll be updating to .92 again! :slight_smile:

I updated to the latest Hass.io version and it’s working. I did notice that when I manually switch the plugs on/off that it’s not recognized as being switched on/off in HA. I downgraded HA again to see if this was a new issue, but it acted the same in 91.4 as well. I guess I just never noticed it before. As a workaround, I created an automation to update all of my EcoPlug entities every 5 minutes. I may lessen that time if it proves to be an issue.

I looked at the code and it’s set up for HA polling. There is a default scan_interval definition and I assumed that it was being be used by HA to check updated status, but it’s not happening. It is shown as deprecated except for single platforms in the docs, so it may be part of the Great Migration impacts. What does work is adding a scan_interval entry to the platform entry in configuration.yaml.

I tested the following option and it takes care of the problem. Add the following to your configuration.yaml and it will update to the manual switch changes with 10 seconds.

switch:
  - platform: ecoplug
    scan_interval: 10

I haven’t tested the effective range of the scan_interval, so you can play with This should eliminate the need for the automation. I’ll update the documentation in GitHub to reflect the required entry.

1 Like

Very nice, never considered integrating some of my existing wion devices with HA, appreciate the effort to do so!

The Python module doesn’t seem to install automatically after a couple restarts. Once I installed it with pip in the docker container, it worked immediately though.

I’m having some trouble getting this to load in HASS.IO. I keep getting the following error on reboot:

    Log Details (ERROR)
Mon May 20 2019 19:01:14 GMT-0700 (Pacific Daylight Time)
Error while setting up platform ecoplug
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py", line 126, in _async_setup_platform
    SLOW_SETUP_MAX_WAIT, loop=hass.loop)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 416, in wait_for
    return fut.result()
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/ecoplug/switch.py", line 49, in setup_platform
    from pyecoplug import EcoDiscovery
ModuleNotFoundError: No module named 'pyecoplug'

Hopefully someone can tell me what I’m doing wrong.

Try editing

custom_components/ecoplug/manifest.json

from

{
  "domain": "ecoplug",
  "name": "Ecoplug",
  "documentation": "https://github.com/gbealmer/pyecoplug/",
  "dependencies": [],
  "codeowners": [],
  "requirements": []
}

to

{
  "domain": "ecoplug",
  "name": "Ecoplug",
  "documentation": "https://github.com/gbealmer/pyecoplug/",
  "dependencies": [],
  "codeowners": [],
  "requirements": ["pyecoplug==0.0.5"]
}

I also added this to the repository, so you can just copy the manifest.json file from there.

This should tell HA to attempt to install the required package. If this doesn’t work, the other option is to install using pip.

Let me know if this works for you. Since my setup was already running, the required package was previously installed. I don’t have a clean system to use to test this change, but based on the new requirements for directory/files including a manifest.json for custom components, I think this will correct the error.

I was facing the same problem. I moved to a hassbian install and the module pyecoplug got installed and the custom component got loaded. The switch was discovered.

I just thought to check this thread again yesterday and set it all up via the new method with the 3 files in the ecoplug folder which is in the custom_component folder which is in my hass.io config folder. I restarted HA twice since the install and do not see any ecoplugs in entities. I posted the only error that appears to be related bellow and next, I am going to power cycle all the devices with fingers crossed. If anyone has any ideas I am all ears and will be researching this error and making sure I followed gbealmer’s new protocol correctly meanwhile. I am running hassio 0.93.2 on a Raspberry Pi 3 via Docker and Raspbian…Update, it appears my manifest.json file didn’t save and was empty. Fixed, restarted, and got the same error so I am deleted the switch.py, and manifest.json but the init.py wouldn’t delete so I saved it as a blank fill, restarted, and now I see the switches in entities so it appears to be working fine. I hope this helps anyone who forgets which touchpad they’re using and hits the wrong side of the pad when they save the manifest file lol!

I had been trying to get this to work for a while so I am very happy and will be donating to gbealmer

–The only error I found so far with the word ecoplug prior to replacing my manifest.json file which I left empty:

Traceback (most recent call last):
File “/usr/local/lib/python3.7/site-packages/homeassistant/helpers/entity_platform.py”, line 126, in _async_setup_platform
SLOW_SETUP_MAX_WAIT, loop=hass.loop)
File “/usr/local/lib/python3.7/asyncio/tasks.py”, line 416, in wait_for
return fut.result()
File “/usr/local/lib/python3.7/concurrent/futures/thread.py”, line 57, in run
result = self.fn(*self.args, **self.kwargs)
File “/config/custom_components/ecoplug/switch.py”, line 49, in setup_platform
from pyecoplug import EcoDiscovery
ModuleNotFoundError: No module named ‘pyecoplug’

Hey @gbealmer, do you have a Patreon, or where can I send you a thank you donation?

No need. All credit for this goes to the original work in

I initially reviewed the code and made a one line change to make it work correctly with HA. This was for my own benefit when I migrated from openHAB.

In openHAB, I was using a hack involving python scripts with some complex rules to control the switches. The integration using a custom component in HA made life much simpler. Any additional work has been my attempt to keep up with migration requirements. If it helps others, that’s an added benefit.

I’ve received far more value from the community than any effort I’ve contributed.

And I’ll throw this out there again… if anyone is up to the challenge, would love a way to statically reference ecoplugs in HA. You can do this with a wemo device and other similar devices, but the HA plugin doesn’t allow it. I tried coding it a few months back and failed.

Since my ecoplug is on another network than Hassio, i’ve been using command line switches, utilizing the homebridge-ecoplug code that is the first post in this thread. Essentially have to ssh from the docker container to the main host that it runs on to run the ssh command, since can’t get node to run within docker. The status switch doesn’t really work…

  - platform: command_line
    switches:
      screened_porch_outlet:
        command_on: 'ssh -i /config/id_rsa user@hassio "/usr/bin/node /opt/hassio/homeassistant/homebridge-ecoplug/PlugControl.js -a on -id ECO-7XXXXF -ip 192.168.90.191"'
        command_off: 'ssh -i /config/id_rsa user@hassio "/usr/bin/node /opt/hassio/homeassistant/homebridge-ecoplug/PlugControl.js -a off -id ECO-7XXXXF -ip 192.168.90.191"'
        #command_state: 'ssh -i /config/id_rsa user@hassio "/usr/bin/node /opt/hassio/homeassistant/homebridge-ecoplug/PlugControl.js -a state -id ECO-7XXXXF -ip 192.168.90.191"'
        friendly_name: Screened Porch Outlet

.99 and it’s failing again. I’m looking into getting some error logs.

Hello,

Just updated to 2021.6 and now the plugin is no longer working.
Here is what the log tells me:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 185, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1491, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1526, in _execute_service
    await handler.job.target(service_call)
  File "/usr/src/homeassistant/homeassistant/components/hassio/__init__.py", line 518, in async_handle_core_service
    raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: The system cannot restart because the configuration is not valid: Platform error switch.ecoplug - Integration 'ecoplug' not found.

Any ideas what the issue could be?

mlewan

1 Like

Seeing this as well; I wonder if something changed with the custom component folder structure? I’m looking into it.

Same issue… Latest HA update broke the ‘ecoplug’. Anyone have any idea as to why or how to fix?

Have to downgrade back as these switches control most of my pool functions.

Looks like the code needs some updating. It fails to run in my container because it uses legacy functions no longer supported in the newer versions of HA.

I’ll try to figure it out.

1 Like

Yes, it even states in my HA log that the new version of HA will not support loading it. Any progress Jeremy?

EDIT: Latest update and restart did nothing, custom_component still not found. There is a ton of stuff under GH issues, I’ll see if someone put one in for the custom issues going on.

Got rid of the deprecation warning, so Python script runs without error in the container. Upgrading core now and seeing how that goes. For some reason the integration still shows missing after running check config. Perhaps the core update / container restart will work?

I noticed some chatter under release notes about several custom components being borked (something about variables); solution was to downgrade :man_facepalming: I’ll edit this post about my findings with the depreciation fix, but I’m not holding my breath.

Will probably end up forking the project later with the updated syntax.

1 Like

Hi, Jeremy, is there any update on this? Still avoiding the HA update because of this. No rush as everything still works with current (downgraded) version.

Just a ping to see if there’s been any progress on this. Just swapped out my Wion ecoplug with a Sonoff so I’m working, but I hate throwing away useable tech.

Thanks in advance!

1 Like