integration ismartgate in domoticz

Others (MiLight, Hue, Toon etc...)

Moderator: leecollings

Post Reply
Filnet
Posts: 38
Joined: Tuesday 06 March 2018 13:55
Target OS: -
Domoticz version:
Contact:

integration ismartgate in domoticz

Post by Filnet »

Hello,
Has anyone done this?
Thank you for your help.
User avatar
waltervl
Posts: 5968
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: integration ismartgate in domoticz

Post by waltervl »

There is a python module for this device so it could be implemented with a Python plugin.
https://github.com/bdraco/ismartgate

If you lack python plugin knowledge you can make a simple python script and have a virtual Domoticz device switch the gate/door.
You should make another python script that polls the status of the gate/door and push the data to Domoticz.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Filnet
Posts: 38
Joined: Tuesday 06 March 2018 13:55
Target OS: -
Domoticz version:
Contact:

Re: integration ismartgate in domoticz

Post by Filnet »

Thank you, waltervi.
I have seen this python plugin.
I will try this solution.
User avatar
waltervl
Posts: 5968
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: integration ismartgate in domoticz

Post by waltervl »

Perhaps an idea is to use AI (chatgpt, copilot etc) to try to create a Domoticz python plugin for it using the existing python module. No idea how it works out but it is the trend.....
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
User avatar
waltervl
Posts: 5968
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: integration ismartgate in domoticz

Post by waltervl »

I did the experiment with Copilot. Not tested so I am wondering it will work:

iSmartGate DomoticzEx Python Plugin
This plugin uses the DomoticzEx framework to integrate your iSmartGate-managed garage doors and gates into Domoticz as Switch devices. It handles login, discovery, command execution, and state synchronization via heartbeat.

Installation
0. Install the python ismartgate module

Code: Select all

pip3 install ismartgate
1. Navigate to your Domoticz plugins folder and create a new directory:

Code: Select all

cd ~/domoticz/plugins
mkdir ismartgate
2. Save the below mentioned plugin code content as plugin.py in folder
~/domoticz/plugins/ismartgate

3. Restart Domoticz:

Code: Select all

sudo systemctl restart domoticz
4. In Domoticz Setup → Hardware, add a new hardware item:

Type: iSmartGate
Name: iSmartGate
Address: <iSmartGate_HOST_OR_IP[:PORT]>
Username: your iSmartGate account email
Password: your iSmartGate password
Mode1: Heartbeat interval in seconds (default 30)

5. Click Add.
Switch devices will be created for each gate/door.

plugin.py code

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)

Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Filnet
Posts: 38
Joined: Tuesday 06 March 2018 13:55
Target OS: -
Domoticz version:
Contact:

Re: integration ismartgate in domoticz

Post by Filnet »

I tried this procedure, but I had to add the argument "--break-system-packages" to pip3 to complete the installation.

Code: Select all

$ pip3 install ismartgate --break-system-packages
...
Installing collected packages: ismartgate
Successfully installed ismartgate-5.0.2
But, I got the following error:

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)
Strangely, when I install ismartgate on another, blank Pi (without Domoticz and other add-ons), ismartgate works fine...
User avatar
waltervl
Posts: 5968
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: integration ismartgate in domoticz

Post by waltervl »

That other system were ismartgate is running is also using Python 3.11?
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Filnet
Posts: 38
Joined: Tuesday 06 March 2018 13:55
Target OS: -
Domoticz version:
Contact:

Re: integration ismartgate in domoticz

Post by Filnet »

Yes,
python 3.11.2 (on the two Raspberry)
User avatar
waltervl
Posts: 5968
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: integration ismartgate in domoticz

Post by waltervl »

Perhaps try

Code: Select all

sudo pip3 install ismartgate --break-system-packages
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Filnet
Posts: 38
Joined: Tuesday 06 March 2018 13:55
Target OS: -
Domoticz version:
Contact:

Re: integration ismartgate in domoticz

Post by Filnet »

I had already this.
I try again now...
The error message is always the same.
User avatar
waltervl
Posts: 5968
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: integration ismartgate in domoticz

Post by waltervl »

I have no real other option. Probably an interference/incompatibility with another python module you have installed on the system...
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Filnet
Posts: 38
Joined: Tuesday 06 March 2018 13:55
Target OS: -
Domoticz version:
Contact:

Re: integration ismartgate in domoticz

Post by Filnet »

Thank you for your help.

I keep your plugin, case of I found the key of my problem.

I do step by step a full installation of my domotic on the second Pi.
Filnet
Posts: 38
Joined: Tuesday 06 March 2018 13:55
Target OS: -
Domoticz version:
Contact:

Re: integration ismartgate in domoticz

Post by Filnet »

Hello waltervi,
...It's me!

I solved my problem: I deleted the folder httpx and reinstall with pip3 ...
Now "ismartgate" works fine.
But... plugin.py make issues:

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.
User avatar
waltervl
Posts: 5968
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: integration ismartgate in domoticz

Post by waltervl »

No idea, I am not a plugin author, just asked AI to create one... Perhaps check with existing plugins if something is incorrect.or ask AI :)
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
FlyingDomotic
Posts: 397
Joined: Saturday 27 February 2016 0:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

Re: integration ismartgate in domoticz

Post by FlyingDomotic »

AI is not smart enough to understand that this is a pyton file, and that first par should be a comment.

Let's try with:

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)

Filnet
Posts: 38
Joined: Tuesday 06 March 2018 13:55
Target OS: -
Domoticz version:
Contact:

Re: integration ismartgate in domoticz

Post by Filnet »

Thanks Flyingdomoticz.

Effectively, your plugin appears in the Hardware's list with the comment header.
But the following of the plugin is not good. The plugin don't find some libraries.


I solved the problem by using os_execute and processing the received response in a dzvents and a device switch 'Door Lock'.
This device command open or close.
I received info every minute for the state Opened/Closed.
I would like that the icon of the Device is update with this info but if I use 'domoticz.devices(DVCE_SWITCH).switchOn().checkFirst()', it's triggers a command. I would want only change the icon, not send a command.
Is'it a solution?
I know it's possible to change icon but I don't where they are.
User avatar
waltervl
Posts: 5968
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: integration ismartgate in domoticz

Post by waltervl »

In dzventz add .silent to the switch command eg

Code: Select all

domoticz.devices(DVCE_SWITCH).switchOn().checkFirst().silent
It will not trigger further actions.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Filnet
Posts: 38
Joined: Tuesday 06 March 2018 13:55
Target OS: -
Domoticz version:
Contact:

Re: integration ismartgate in domoticz

Post by Filnet »

Fantastic!!
I hav'nt sawn this add in the doc!

Thank you for your help.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest