integration ismartgate in domoticz
Posted: Monday 21 July 2025 23:59
Hello,
Has anyone done this?
Thank you for your help.
Has anyone done this?
Thank you for your help.
Open source Home Automation System
https://forum.domoticz.com/
Code: Select all
pip3 install ismartgate
Code: Select all
cd ~/domoticz/plugins
mkdir ismartgate
Code: Select all
sudo systemctl restart domoticz
Code: Select all
<plugin key="ismartgate" name="iSmartGate" author="Walter" version="1.0" externallink="https://github.com/bdraco/ismartgate">
<description>
<h2>iSmartGate Integration (DomoticzEx)</h2>
Discover and control all your iSmartGate garage doors and gates as Domoticz switches.
</description>
<params>
<param field="Address" label="iSmartGate Host/IP[:Port]" width="200px" required="true"/>
<param field="Username" label="Username (email)" width="200px" required="true"/>
<param field="Password" label="Password" width="200px" required="true" password="true"/>
<param field="Mode1" label="Heartbeat Interval (seconds)" width="50px" required="true" default="30"/>
</params>
</plugin>
import DomoticzEx as D
import ismartgate
class Plugin(D.Plugin):
def __init__(self):
super().__init__()
self.gate = None
self.unit_map = {}
def onStart(self):
D.Log("iSmartGate Plugin starting")
host = D.Parameters["Address"]
user = D.Parameters["Username"]
pwd = D.Parameters["Password"]
interval = D.intParam("Mode1", 30)
D.Heartbeat(interval)
try:
self.gate = ismartgate.ISmartGate(host)
self.gate.login(user, pwd)
D.Log("Logged in to iSmartGate")
except Exception as e:
D.LogError(f"Login failed: {e}")
return
try:
self.gate.get_devices()
unit = 1
for dev_id, dev in sorted(self.gate.devices.items()):
name = dev.friendly_name or f"Gate {dev_id}"
if unit not in D.Devices:
D.Device(Unit=unit, Name=name, TypeName="Switch").Create()
D.Log(f"Created device {unit}: {name}")
self.unit_map[unit] = dev_id
unit += 1
except Exception as e:
D.LogError(f"Device discovery failed: {e}")
def onHeartbeat(self):
if not self.gate:
return
try:
self.gate.get_devices()
for unit, dev_id in self.unit_map.items():
device = D.Devices[unit]
state = self.gate.devices[dev_id].state
nVal = 1 if state else 0
sVal = str(nVal)
if device.nValue != nVal:
D.Log(f"Updating {device.Name} → {'On' if nVal else 'Off'}")
device.Update(nValue=nVal, sValue=sVal)
except Exception as e:
D.LogError(f"Heartbeat error: {e}")
def onCommand(self, Unit, Command, Level, Hue):
if Unit not in self.unit_map or not self.gate:
return
dev_id = self.unit_map[Unit]
try:
if Command == "On":
D.Log(f"Opening device {dev_id}")
self.gate.open(dev_id)
elif Command == "Off":
D.Log(f"Closing device {dev_id}")
self.gate.close(dev_id)
else:
D.Log(f"Ignored unsupported command: {Command}")
except Exception as e:
D.LogError(f"Command error: {e}")
# Create plugin instance
global _plugin
_plugin = Plugin()
def onStart(): _plugin.onStart()
def onStop(): _plugin.onStop()
def onHeartbeat(): _plugin.onHeartbeat()
def onCommand(Unit, Command, Level, Hue): _plugin.onCommand(Unit, Command, Level, Hue)
Code: Select all
$ pip3 install ismartgate --break-system-packages
...
Installing collected packages: ismartgate
Successfully installed ismartgate-5.0.2
Code: Select all
$ ismartgate
Traceback (most recent call last):
File "/home/pi/.local/bin/ismartgate", line 5, in <module>
from ismartgate.cli import ismartgate_cli
File "/home/pi/.local/lib/python3.11/site-packages/ismartgate/__init__.py", line 17, in <module>
from httpx import AsyncClient, RemoteProtocolError, Response
ImportError: cannot import name 'AsyncClient' from 'httpx' (/usr/local/lib/python3.11/dist-packages/httpx-1.0.dev1-py3.11.egg/httpx/__init__.py)
Code: Select all
sudo pip3 install ismartgate --break-system-packages
Code: Select all
2025-07-25 16:11:55.556 Error: iSmartGate: (ismartgate) failed to load 'plugin.py', Python Path used was '/home/pi/domoticz/plugins/ismartgate/:/usr/lib/python311.zip:/usr/lib/python3.11:/usr/lib/python3.11/lib-dynload:/usr/local/lib/python3.11/dist-packages:/usr/lib/python3/dist-packages:/usr/lib/python3.11/dist-packages'.
2025-07-25 16:11:55.577 Error: iSmartGate: Exception: 'SyntaxError'. No traceback available.
Code: Select all
"""
<plugin key="ismartgate" name="iSmartGate" author="Walter" version="1.0" externallink="https://github.com/bdraco/ismartgate">
<description>
<h2>iSmartGate Integration (DomoticzEx)</h2>
Discover and control all your iSmartGate garage doors and gates as Domoticz switches.
</description>
<params>
<param field="Address" label="iSmartGate Host/IP[:Port]" width="200px" required="true"/>
<param field="Username" label="Username (email)" width="200px" required="true"/>
<param field="Password" label="Password" width="200px" required="true" password="true"/>
<param field="Mode1" label="Heartbeat Interval (seconds)" width="50px" required="true" default="30"/>
</params>
</plugin>
"""
import DomoticzEx as D
import ismartgate
class Plugin(D.Plugin):
def __init__(self):
super().__init__()
self.gate = None
self.unit_map = {}
def onStart(self):
D.Log("iSmartGate Plugin starting")
host = D.Parameters["Address"]
user = D.Parameters["Username"]
pwd = D.Parameters["Password"]
interval = D.intParam("Mode1", 30)
D.Heartbeat(interval)
try:
self.gate = ismartgate.ISmartGate(host)
self.gate.login(user, pwd)
D.Log("Logged in to iSmartGate")
except Exception as e:
D.LogError(f"Login failed: {e}")
return
try:
self.gate.get_devices()
unit = 1
for dev_id, dev in sorted(self.gate.devices.items()):
name = dev.friendly_name or f"Gate {dev_id}"
if unit not in D.Devices:
D.Device(Unit=unit, Name=name, TypeName="Switch").Create()
D.Log(f"Created device {unit}: {name}")
self.unit_map[unit] = dev_id
unit += 1
except Exception as e:
D.LogError(f"Device discovery failed: {e}")
def onHeartbeat(self):
if not self.gate:
return
try:
self.gate.get_devices()
for unit, dev_id in self.unit_map.items():
device = D.Devices[unit]
state = self.gate.devices[dev_id].state
nVal = 1 if state else 0
sVal = str(nVal)
if device.nValue != nVal:
D.Log(f"Updating {device.Name} → {'On' if nVal else 'Off'}")
device.Update(nValue=nVal, sValue=sVal)
except Exception as e:
D.LogError(f"Heartbeat error: {e}")
def onCommand(self, Unit, Command, Level, Hue):
if Unit not in self.unit_map or not self.gate:
return
dev_id = self.unit_map[Unit]
try:
if Command == "On":
D.Log(f"Opening device {dev_id}")
self.gate.open(dev_id)
elif Command == "Off":
D.Log(f"Closing device {dev_id}")
self.gate.close(dev_id)
else:
D.Log(f"Ignored unsupported command: {Command}")
except Exception as e:
D.LogError(f"Command error: {e}")
# Create plugin instance
global _plugin
_plugin = Plugin()
def onStart(): _plugin.onStart()
def onStop(): _plugin.onStop()
def onHeartbeat(): _plugin.onHeartbeat()
def onCommand(Unit, Command, Level, Hue): _plugin.onCommand(Unit, Command, Level, Hue)
Code: Select all
domoticz.devices(DVCE_SWITCH).switchOn().checkFirst().silent