fauxmo user plugin not found
sikalabsga opened this issue · 8 comments
I'm experiencing the module not found error. In my working directory, I have created a user plugin following @n8henrie example and also followed with the naming convention, called switcherplugin.py . In the same folder a created a venv and activated it and then installed fauxmo. However, when I run fauxmo -c config.json [-v] I get the error that my custom python plugin is not found. 'fauxmo.plugins.switcherplugin'.
config.json
{
"FAUXMO": {
"ip_address": "auto"
},
"PLUGINS": {
"SwitcherPlugin": {
"path": "~/MyHomeAutomationServer/switcherplugin.py",
"DEVICES": [
{
"port": 12340,
"name": "garage"
},
{
"port": 12341,
"name": "coffee-marker"
}
]
},
"SimpleHTTPPlugin": {
"DEVICES": [
{
"port": 12340, "on_cmd": "http://192.168.1.127/myserver/fakeswitches/01/on", "off_cmd": "http://192.168.1.127/myserver/fakeswitches/01/off", "method": "GET", "name": "fake switch one"
},
{
"port": 12341, "on_cmd": "http://localhost:54321/devices/garage%20light", "off_cmd": "http://localhost:54321/devices/garage%20light", "on_data": {"isOn": 1}, "off_data": {"isOn": 0}, "user": "this", "password": "that", "method": "PUT", "name": "fake Indigo switch"
},
{
"name": "fake home assistant switch by REST API", "port": 12342, "on_cmd": "http://192.168.1.127:8123/api/services/switch/turn_on", "off_cmd": "http://192.168.1.127:8123/api/services/switch/turn_off", "method": "POST", "headers": {"x-ha-access": "your_hass_password"}, "on_data": {"entity_id": "switch.fake_hass_switch"}, "off_data": {"entity_id": "switch.fake_hass_switch"}
}
]
}
}
}
userplugin: switcherplugin.py
from fauxmo.plugins import FauxmoPlugin
class SwitcherPlugin(FauxmoPlugin):
"""
Publishes the on/off state requested,
and the IP address of the Echo making the request.
"""
def __init__(self, name: str, port: int) -> None:
super().__init__(name=name, port=port)
def on(self):
"""Turn the named device on.
Returns: Whether the device seems to have been turned on.
"""
pass
def off(self):
"""Turn the named device off.
Returns: Whether the device seems to have been turned off.
"""
pass
def get_state(self):
"""Query the state of the Home Assistant device.
Returns: Device state as reported by HomeAssistant
"""
pass
Thanks for the fresh issue. I cleaned up some codeblocks -- please make sure to use them.
First step would be to replace "~/MyHomeAutomationServer/switcherplugin.py"
with the absolute path to the file (without ~
) -- see if that helps.
EDIT: Please also follow the issue template in its entirety -- if that doesn't fix it, I'll need to see a verbose log.
Thanks for quick response, however that didn't fix it.
Here is the error:
ModuleNotFoundError: No module named 'fauxmo.plugins.switcherplugin'
Please include the full log.
File "/home/pi/MyHomeAutomationServer/venv/lib/python3.7/site-packages/fauxmo/fauxmo.py", line 95, in main
module = importlib.import_module(modname)
File "/usr/lib/python3.7/importlib/init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "", line 1006, in _gcd_import
File "", line 983, in _find_and_load
File "", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'fauxmo.plugins.switcherplugin
Did you solve the issue?
Would you mind sharing the solution for future users?
There was an error in my switcherplugin.py which lead to it not being found. i wanted to have access to the name property in the ini function in all there three other functions, on(), off() n get_state() and ended up confusing things.