TP-Link smart plug HS100/HS110

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

Moderator: leecollings

DaanV
Posts: 14
Joined: Thursday 02 May 2019 11:14
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: TP-Link smart plug HS100/HS110

Post by DaanV »

It is working now. Thank you so much for getting this to work!
Geitje
Posts: 170
Joined: Monday 22 January 2018 21:52
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: TP-Link smart plug HS100/HS110

Post by Geitje »

Thanks Ajay100 and other for this useful script.

From what I read and experience this script does only report back to Domoticz the state of HS110 plugs. I only use HS100 plugs. On/off switch does work perfect, but if I switch them using TPlinks own Kasa app, Domoticz does not notice.

Could you make a version which also reports the state of the HS100 to Domoticz?
Domoticz beta, on Raspberry Pi 3B, Raspian Buster
Zwave, Zigate, RFlink etc.
ajay100
Posts: 72
Joined: Monday 07 August 2017 15:01
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Victoria, Australia
Contact:

Re: TP-Link smart plug HS100/HS110

Post by ajay100 »

@Geitje, this Domoticz HS100/110 plugin https://github.com/dahallgren/domoticz-tplink-smartplug should work with your HS100. I have Domoticz on a RPi (debian based) system, so I can only speak for that and testing with the HS110. My script will also work, but this plugin is more directly a 'Domoticz' solution.

It is easier if you install the Python Plugin Manager first, as per this thread: https://www.domoticz.com/forum/viewtopi ... in+manager

I've just checked and the plugin needed a small code change to make it report the switch state at the heartbeat intervals rather than just on starting. This change is just duplicating the switch state code from the onStart script to the onHeartbeat script.

Code: Select all

    def onHeartbeat(self):
        if self.heartbeatcounter % self.interval == 0:
          self.update_emeter_values()
          
          # Get the switch state as well.
          state = self.get_switch_state()
          if state in 'off':
              Devices[1].Update(0, '0')
          elif state in 'on':
              Devices[1].Update(1, '100')
          else:
              Devices[1].Update(1, '50')
            
        self.heartbeatcounter += 1
You could comment out

Code: Select all

          self.update_emeter_values()
for an HS100, but that is not necessary.

I would also change the interval

Code: Select all

self.interval = 6  # 6*10 seconds
to 1 (around 10 seconds) in __init__ for faster switch updates.

Cheers - Andrew
Geitje
Posts: 170
Joined: Monday 22 January 2018 21:52
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: TP-Link smart plug HS100/HS110

Post by Geitje »

@Andrew,

Thanks for your swift reply. I will try it soon. Thanks for your proposals for code change, also makes me more familiar with coding!
Domoticz beta, on Raspberry Pi 3B, Raspian Buster
Zwave, Zigate, RFlink etc.
Geitje
Posts: 170
Joined: Monday 22 January 2018 21:52
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: TP-Link smart plug HS100/HS110

Post by Geitje »

@ Andrew:

When debuggin and running the script in Domoticz I get a syntax error in your additions to script. I think I removed all windows line endings....

Python 3.5.3 (/usr/bin/python3)
>>> %cd /home/pi/domoticz/plugins/domoticz-tplink-smartplug
>>> %Debug plugin.py
File "/home/pi/domoticz/plugins/domoticz-tplink-smartplug/plugin.py", line 139
state = self.get_switch_state()
^
SyntaxError: unindent does not match any outer indentation level

>>> %Debug plugin.py
File "/home/pi/domoticz/plugins/domoticz-tplink-smartplug/plugin.py", line 139
state = self.get_switch_state()
^
Domoticz beta, on Raspberry Pi 3B, Raspian Buster
Zwave, Zigate, RFlink etc.
ajay100
Posts: 72
Joined: Monday 07 August 2017 15:01
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Victoria, Australia
Contact:

Re: TP-Link smart plug HS100/HS110

Post by ajay100 »

@Geitje, check your indents visually against what I have posted (spaces or tabs in code), as Python uses these to detect the correct 'grouping' of the statements. The amount of spaces is not important, as long as it is consistently equivalent to what I have posted. When you copy and paste, sometimes the correct spacing is lost.
Geitje
Posts: 170
Joined: Monday 22 January 2018 21:52
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: TP-Link smart plug HS100/HS110

Post by Geitje »

@ Andrew
Ah, so that I did not know. Apperently the spaces were not equivalent everywhere. Thanks, works now! Also the feedback to Domoticz when switching using TPlinks own KASA app works. Thanks!
Domoticz beta, on Raspberry Pi 3B, Raspian Buster
Zwave, Zigate, RFlink etc.
User avatar
lordzurp
Posts: 2
Joined: Monday 22 July 2019 11:19
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Lyon, France
Contact:

Re: TP-Link smart plug HS100/HS110

Post by lordzurp »

Hello guys !

this is my first post on this board (but not first on a board ...)

I just made a fresh install of my rPI with domoticz, and finally set up a clean way to manage HS110 plug

I started with this plugin : https://github.com/dahallgren/domoticz-tplink-smartplug, tweaked a little with some helpfully pieces of code from previous replies, and a pinch of homemade code

I had to manage with the 2 versions of HS110, v1 which speak in full units, and the v2 which work with millis

here is the result : https://github.com/lordzurp/domoticz-tplink-smartplug

New device type

Code: Select all

                <option label="HS100" value="HS100" default="true"/>
                <option label="HS110" value="HS110"  default="false"/>
                <option label="HS110v2" value="HS110v2"  default="false"/>
change Domoticz device type, to properly report power consumption

Code: Select all

            Domoticz.Device(Name="(W)", Unit=4, Type=243, Subtype=29).Create()
rounded results, to avoid 2.377066 useless headhache, and adding the total power consumption reported by the plug

Code: Select all

                Devices[2].Update(nValue=0, sValue=str(round(realtime_result['current'],2)))
                Devices[3].Update(nValue=0, sValue=str(round(realtime_result['voltage'],2)))
                Devices[4].Update(nValue=0, sValue=str(round(realtime_result['power'],2)) + ";" + str(realtime_result['total']*1000))
a new branch for v2, with /1000 scaling

Code: Select all

        if Parameters["Mode1"] == "HS110v2":
            [...]
                Devices[2].Update(nValue=0, sValue=str(round(realtime_result['current_ma']/1000,2)))
                Devices[3].Update(nValue=0, sValue=str(round(realtime_result['voltage_mv']/1000,2)))
                Devices[4].Update(nValue=0, sValue=str(round(realtime_result['power_mw']/1000,2)) + ";" + str(realtime_result['total_wh']))
and minor corrections to work with the new v2 type

hopefully it will work on your system :)
A guy with a (lot of) server, in the basement
ajay100
Posts: 72
Joined: Monday 07 August 2017 15:01
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Victoria, Australia
Contact:

Re: TP-Link smart plug HS100/HS110

Post by ajay100 »

@lordzurp, welcome! Thanks for this more generic solution, I like that flexibility.
User avatar
LouiS22
Posts: 433
Joined: Friday 27 February 2015 13:21
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Budapest, Hungary
Contact:

Re: TP-Link smart plug HS100/HS110

Post by LouiS22 »

lordzurp wrote: Monday 22 July 2019 11:37 Hello guys !

this is my first post on this board (but not first on a board ...)

I just made a fresh install of my rPI with domoticz, and finally set up a clean way to manage HS110 plug

I started with this plugin : https://github.com/dahallgren/domoticz-tplink-smartplug, tweaked a little with some helpfully pieces of code from previous replies, and a pinch of homemade code

I had to manage with the 2 versions of HS110, v1 which speak in full units, and the v2 which work with millis

here is the result : https://github.com/lordzurp/domoticz-tplink-smartplug

New device type

Code: Select all

                <option label="HS100" value="HS100" default="true"/>
                <option label="HS110" value="HS110"  default="false"/>
                <option label="HS110v2" value="HS110v2"  default="false"/>
change Domoticz device type, to properly report power consumption

Code: Select all

            Domoticz.Device(Name="(W)", Unit=4, Type=243, Subtype=29).Create()
rounded results, to avoid 2.377066 useless headhache, and adding the total power consumption reported by the plug

Code: Select all

                Devices[2].Update(nValue=0, sValue=str(round(realtime_result['current'],2)))
                Devices[3].Update(nValue=0, sValue=str(round(realtime_result['voltage'],2)))
                Devices[4].Update(nValue=0, sValue=str(round(realtime_result['power'],2)) + ";" + str(realtime_result['total']*1000))
a new branch for v2, with /1000 scaling

Code: Select all

        if Parameters["Mode1"] == "HS110v2":
            [...]
                Devices[2].Update(nValue=0, sValue=str(round(realtime_result['current_ma']/1000,2)))
                Devices[3].Update(nValue=0, sValue=str(round(realtime_result['voltage_mv']/1000,2)))
                Devices[4].Update(nValue=0, sValue=str(round(realtime_result['power_mw']/1000,2)) + ";" + str(realtime_result['total_wh']))
and minor corrections to work with the new v2 type

hopefully it will work on your system :)
Thanks, working as expected. Finally I could forget my previous cron based bash script to catch data :)
User avatar
lordzurp
Posts: 2
Joined: Monday 22 July 2019 11:19
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Lyon, France
Contact:

Re: TP-Link smart plug HS100/HS110

Post by lordzurp »

ajay100 wrote: Monday 22 July 2019 12:37
you're welcome :)
LouiS22 wrote: Monday 22 July 2019 14:37 Thanks, working as expected. Finally I could forget my previous cron based bash script to catch data :)
same here. I lost my crontab when I reflashed the µSD, so got in search of a proper solution, and voila :)

glad to know it works elsewhere than in my lab !
A guy with a (lot of) server, in the basement
Geitje
Posts: 170
Joined: Monday 22 January 2018 21:52
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: TP-Link smart plug HS100/HS110

Post by Geitje »

Right now I have 4 TP link HS100 plugs running. It all works, but for some reason I get the following error every some minutes:

Code: Select all

2019-07-28 22:24:57.749 Error: (TPlink HS 100 IP.8) 'onCommand' failed 'timeout'.
2019-07-28 22:24:57.750 Error: (TPlink HS 100 IP.8) ----> Line 275 in '/home/pi/domoticz/plugins/domoticz-tplink-smartplug/plugin.py', function onCommand
2019-07-28 22:24:57.750 Error: (TPlink HS 100 IP.8) ----> Line 116 in '/home/pi/domoticz/plugins/domoticz-tplink-smartplug/plugin.py', function onCommand
2019-07-28 22:24:57.750 Error: (TPlink HS 100 IP.8) ----> Line 178 in '/home/pi/domoticz/plugins/domoticz-tplink-smartplug/plugin.py', function _send_json_cmd
2019-07-28 22:25:00.272 Error: (TPlink HS 100 IP.8) 'onHeartbeat' failed 'timeout'.
2019-07-28 22:25:00.272 Error: (TPlink HS 100 IP.8) ----> Line 290 in '/home/pi/domoticz/plugins/domoticz-tplink-smartplug/plugin.py', function onHeartbeat
2019-07-28 22:25:00.272 Error: (TPlink HS 100 IP.8) ----> Line 138 in '/home/pi/domoticz/plugins/domoticz-tplink-smartplug/plugin.py', function onHeartbeat
2019-07-28 22:25:00.272 Error: (TPlink HS 100 IP.8) ----> Line 236 in '/home/pi/domoticz/plugins/domoticz-tplink-smartplug/plugin.py', function get_switch_state
2019-07-28 22:25:00.272 Error: (TPlink HS 100 IP.8) ----> Line 178 in '/home/pi/domoticz/plugins/domoticz-tplink-smartplug/plugin.py', function _send_json_cmd
Does it mean the Domoticz plugin can't reach the HS100 plug, and gives this error?

So I changed all my HS100 adapters to @lordzurp's plugin. But the error persisted. I then increased the self.interval value to 12, but it does not seem to improve anything. My Domoticz crashes about every week, and all pyton plugins crash a ouple of times a day, and I suspect these errors of crashing the Python system. Anyone knows how to get rid of these?
Domoticz beta, on Raspberry Pi 3B, Raspian Buster
Zwave, Zigate, RFlink etc.
ajay100
Posts: 72
Joined: Monday 07 August 2017 15:01
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Victoria, Australia
Contact:

Re: TP-Link smart plug HS100/HS110

Post by ajay100 »

Hi @Geitje, the error is occurring in the _send_json_cmd(self, cmd) function. There is 'a timeout on blocking socket operations' of 1.5 seconds in this line

Code: Select all

sock.settimeout(1.5)
The script is not receiving a response from the HS100 in 1.5 seconds, so it is continuing on, rather than crashing (script stops running) or blocking (appearing to freeze).

Some things to check would be:
1. Reliable WiFi connection for all switches i.e. distance from router. The HS110 wifi icon is solid green when connected, hopefully the same on HS100.
2. Maybe occasional interference between switches?
3. Increasing the timeout.

Unfortunately I don't have multiple switches to test with myself. These particular errors are not necessarily a problem, however the plugins and Domoticz crashing would be annoying and shouldn't be happening.

I think I did get some crashing of the plugin system when I tried it, so I went back to using the standalone python scripts mentioned elsewhere in this thread, which have been rock solid now for over a year and Domoticz doesn't crash at all. I will start up the plugin manager again to see what happens.

Cheers - Andrew
Geitje
Posts: 170
Joined: Monday 22 January 2018 21:52
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: TP-Link smart plug HS100/HS110

Post by Geitje »

Thanks! I set sock.settimeout to 6.5, let you know if it helps.
Domoticz beta, on Raspberry Pi 3B, Raspian Buster
Zwave, Zigate, RFlink etc.
CV8R
Posts: 21
Joined: Thursday 27 September 2018 7:13
Target OS: Linux
Domoticz version:
Contact:

Re: TP-Link smart plug HS100/HS110

Post by CV8R »

Hi @ajay100

I have been using your script with great success although I found that the addition of the heartbeat status update was spamming the domoticz switch log every heartbeat.

I added a var to track the status and only send status on heartbeat if diff from last status. I can share, but my coding is poor and very simple for you to add.

I also found during testing for this minor change that the timeout errors when the unit is off or cannot be contacted. Unfortunately, handling those is above my python skill level.

Regards
CV8R
ajay100
Posts: 72
Joined: Monday 07 August 2017 15:01
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Victoria, Australia
Contact:

Re: TP-Link smart plug HS100/HS110

Post by ajay100 »

Thanks for the info @CV8R. I agree the errors are annoying when the device is switched off. I'll see if something can be done about that in a few weeks when I have my hands on the HS110 again.

Cheers - Andrew
Geitje
Posts: 170
Joined: Monday 22 January 2018 21:52
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: TP-Link smart plug HS100/HS110

Post by Geitje »

Geitje wrote: Monday 29 July 2019 10:36 Thanks! I set sock.settimeout to 6.5, let you know if it helps.
It helped: I get the errors now and then still, but much less than before. Also: no crashes anymore.

@CV8R: maybe this helps you also?
Domoticz beta, on Raspberry Pi 3B, Raspian Buster
Zwave, Zigate, RFlink etc.
ajay100
Posts: 72
Joined: Monday 07 August 2017 15:01
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10717
Location: Victoria, Australia
Contact:

Re: TP-Link smart plug HS100/HS110

Post by ajay100 »

Thanks for getting back @Geitje.

Cheers - Andrew
CV8R
Posts: 21
Joined: Thursday 27 September 2018 7:13
Target OS: Linux
Domoticz version:
Contact:

Re: TP-Link smart plug HS100/HS110

Post by CV8R »

Thanks for the info @CV8R. I agree the errors are annoying when the device is switched off. I'll see if something can be done about that in a few weeks when I have my hands on the HS110 again.
Cheers Andrew. Apologies, I wasn't subscribed to the thread. Sorted now.

@Geitje the timeout won't help the above errors when the device is off but thanks for the thought.

CV8R
jaaap
Posts: 59
Joined: Sunday 28 July 2019 22:59
Target OS: NAS (Synology & others)
Domoticz version:
Contact:

Re: TP-Link smart plug HS100/HS110

Post by jaaap »

Hi all,

After reading all the posts, I've come a long way and I'm almost there. Maybe someone can help me with the last bits of code?

Here's what is happening: I've put Ajay100's python3 script in a folder of domoticz. I can get it to perform some commands from the command line (on, off, info, and energy). However, with the last command, energy, putty gets stuck. In the log file I get the following:

Code: Select all

2019-09-23 13:19:59,447:__main__:INFO:hs110-3 version 3.5 has started...
2019-09-23 13:19:59,455:__main__:DEBUG:Command: {"emeter":{"get_realtime":{}}}
2019-09-23 13:19:59,456:__main__:DEBUG:Encoded string: b'{"emeter":{"get_realtime":{}}}'
2019-09-23 13:19:59,456:__main__:DEBUG:Encrypted Command: b'\x00\x00\x00\x1e\xd0\xf2\x97\xfa\x9f\xeb\x8e\xfc\xde\xe4\x9f\xbd\xda\xbf\xcb\x94\xe6\x83\xe2\x8e\xfa\x93\xfe\x9b\xb9\x83\xf8\x85\xf8\x85'
2019-09-23 13:19:59,457:__main__:DEBUG:Encoded string: b'{"emeter":{"get_realtime":{}}}'
2019-09-23 13:19:59,502:__main__:DEBUG:data: b'\x00\x00\x00h\xd0\xf2\x97\xfa\x9f\xeb\x8e\xfc\xde\xe4\x9f\xbd\xda\xbf\xcb\x94\xe6\x83\xe2\x8e\xfa\x93\xfe\x9b\xb9\x83\xf8\xda\xac\xc3\xaf\xdb\xba\xdd\xb8\xe7\x8a\xfc\xde\xe4\xd6\xe2\xd2\xe6\xd4\xed\xc1\xe3\x80\xf5\x87\xf5\x90\xfe\x8a\xd5\xb8\xd9\xfb\xc1\xf0\xc6\xea\xc8\xb8\xd7\xa0\xc5\xb7\xe8\x85\xf2\xd0\xea\xda\xf6\xd4\xa0\xcf\xbb\xda\xb6\xe9\x9e\xf6\xd4\xee\xd7\xfb\xd9\xbc\xce\xbc\xe3\x80\xef\x8b\xee\xcc\xf6\xc6\xbb\xc6\xbb'
2019-09-23 13:19:59,503:__main__:DEBUG:Sent:     {"emeter":{"get_realtime":{}}}
2019-09-23 13:19:59,503:__main__:DEBUG:Received: {"emeter":{"get_realtime":{"voltage_mv":240429,"current_ma":16,"power_mw":0,"total_wh":9,"err_code":0}}}
2019-09-23 13:19:59,504:__main__:DEBUG:json_data: {'emeter': {'get_realtime': {'total_wh': 9, 'power_mw': 0, 'current_ma': 16, 'err_code': 0, 'voltage_mv': 240429}}}
2019-09-23 13:19:59,504:__main__:DEBUG:IDX: 37, Item: voltage, Value: 240.43
2019-09-23 13:19:59,505:__main__:DEBUG:URL: http://192.168.2.1:8084/json.htm?type=command&param=udevice&nvalue=0&idx=37&svalue=240.43
2019-09-23 13:19:59,527:__main__:ERROR:HTTP error(None): None
2019-09-23 13:19:59,530:__main__:DEBUG:Command: {"system":{"get_sysinfo":{}}}
2019-09-23 13:19:59,531:__main__:DEBUG:Encoded string: b'{"system":{"get_sysinfo":{}}}'
2019-09-23 13:19:59,531:__main__:DEBUG:Encrypted Command: b'\x00\x00\x00\x1d\xd0\xf2\x81\xf8\x8b\xff\x9a\xf7\xd5\xef\x94\xb6\xd1\xb4\xc0\x9f\xec\x95\xe6\x8f\xe1\x87\xe8\xca\xf0\x8b\xf6\x8b\xf6'
2019-09-23 13:19:59,531:__main__:DEBUG:Encoded string: b'{"system":{"get_sysinfo":{}}}'
2019-09-23 13:19:59,612:__main__:DEBUG:data: b'\x00\x00\x02d\xd0\xf2\x81\xf8\x8b\xff\x9a\xf7\xd5\xef\x94\xb6\xd1\xb4\xc0\x9f\xec\x95\xe6\x8f\xe1\x87\xe8\xca\xf0\x8b\xa9\xda\xad\xf2\x84\xe1\x93\xb1\x8b\xa9\x98\xb6\x83\xad\x99\xb9\xfb\x8e\xe7\x8b\xef\xcf\xfe\xc6\xf6\xce\xff\xca\xea\xb8\xdd\xb1\x9f\xae\x9c\xad\x99\xad\x9d\xbf\x93\xb1\xd9\xae\xf1\x87\xe2\x90\xb2\x88\xaa\x98\xb6\x86\xa4\x88\xaa\xde\xa7\xd7\xb2\x90\xaa\x88\xc1\x8e\xda\xf4\xa7\xea\xab\xf9\xad\xfd\xb1\xe4\xa3\xf0\xa7\xee\xba\xf9\xb1\x93\xbf\x9d\xf0\x9f\xfb\x9e\xf2\xd0\xea\xc8\x80\xd3\xe2\xd3\xe3\xcb\x8e\xdb\xf2\xd0\xfc\xde\xb3\xd2\xb1\x93\xa9\x8b\xb2\x8a\xb0\xf4\xb5\x8f\xcc\xf8\xc2\xf4\xb5\x8f\xb8\xf9\xc3\xf5\xb3\x91\xbd\x9f\xfb\x9e\xe8\xb7\xd9\xb8\xd5\xb0\x92\xa8\x8a\xd9\xb4\xd5\xa7\xd3\xf3\xa4\xcd\xe0\xa6\xcf\xef\xbf\xd3\xa6\xc1\xe1\xb6\xdf\xab\xc3\xe3\xa6\xc8\xad\xdf\xb8\xc1\xe1\xac\xc3\xad\xc4\xb0\xdf\xad\xc4\xaa\xcd\xef\xc3\xe1\x80\xec\x85\xe4\x97\xb5\x8f\xad\xda\xbb\xc8\xa5\xc4\xa7\xcf\xa6\xc8\xad\x80\xed\x88\xfc\x99\xeb\xc9\xe5\xc7\xb5\xd0\xbc\xdd\xa4\xfb\x88\xfc\x9d\xe9\x8c\xae\x94\xa5\x89\xab\xc4\xaa\xf5\x81\xe8\x85\xe0\xc2\xf8\xc0\xf4\xcc\xe0\xc2\xa3\xc0\xb4\xdd\xab\xce\x91\xfc\x93\xf7\x92\xb0\x8a\xa8\xc6\xa9\xc7\xa2\x80\xac\x8e\xe8\x8d\xec\x98\xed\x9f\xfa\xd8\xe2\xc0\x94\xdd\x90\xaa\xef\xa1\xe4\xc6\xea\xc8\xbd\xcd\xa9\xc8\xbc\xd5\xbb\xdc\xfe\xc4\xf4\xd8\xfa\x93\xf0\x9f\xf1\xae\xc6\xa7\xd4\xbc\x9e\xa4\x86\xa4\x88\xaa\xd8\xab\xd8\xb1\x93\xa9\x84\xb1\x89\xa5\x87\xeb\x8e\xea\xb5\xda\xbc\xda\xf8\xc2\xf2\xde\xfc\x90\xff\x91\xf6\x9f\xeb\x9e\xfa\x9f\xc0\xa9\x8b\xb1\x81\xad\x8f\xe3\x82\xf6\x9f\xeb\x9e\xfa\x9f\xc0\xa9\x8b\xb1\x81\xad\x8f\xe7\x90\xd9\xbd\x9f\xa5\x87\xb7\x83\xb7\xf6\xc3\xf2\xc4\x81\xc4\xf2\xc1\x82\xba\x8d\xb8\xfe\xc7\xf3\xc6\xfe\xba\xfb\xc9\xfc\xbf\x8d\xce\x8d\xce\xfb\xba\x8a\xa8\x84\xa6\xc0\xb7\xfe\x9a\xb8\x82\xa0\x90\xa0\x90\xa0\x90\xa0\x90\xa0\x90\xa0\x90\xa0\x90\xa0\x90\xa0\x90\xa0\x90\xa0\x90\xa0\x90\xa0\x90\xa0\x90\xa0\x90\xa0\x90\xa0\x82\xae\x8c\xe8\x8d\xfb\x92\xf1\x94\xdd\xb9\x9b\xa1\x83\xbb\x8b\xbb\x8d\xcc\x89\xb0\xf6\xc0\xf3\xc5\x87\xc3\x81\xc2\xf0\xc0\xf9\xbb\x8a\xb3\xf2\xb3\xf1\xc7\xf3\xc1\xf9\xce\xf9\xcf\xfc\xcd\x8f\xce\x8f\xcd\xff\xbe\x87\xa5\x89\xab\xc4\xa1\xcc\x85\xe1\xc3\xf9\xdb\xea\xd3\xea\xd2\x93\xa2\x96\xd2\x93\xd2\xea\xdc\x99\xad\xe8\xd8\xe8\xd9\x9f\xdb\xec\xaf\xee\xa8\x9c\xae\x96\xa0\x98\xda\xef\xaa\x88\xa4\x86\xe8\x8d\xf5\x81\xde\xbf\xdc\xa8\xc1\xae\xc0\xe2\xd8\xa3\x81\xf5\x8c\xfc\x99\xbb\x81\xac\x9d\xe0\xcc\xee\x8b\xf9\x8b\xd4\xb7\xd8\xbc\xd9\xfb\xc1\xf1\x8c\xf1\x8c'
2019-09-23 13:19:59,613:__main__:DEBUG:Sent:     {"system":{"get_sysinfo":{}}}
2019-09-23 13:19:59,613:__main__:DEBUG:Received: {"system":{"get_sysinfo":{"sw_ver":"1.5.4 Build 180815 Rel.121440","hw_ver":"2.0","type":"IOT.SMARTPLUGSWITCH","model":"HS110(EU)","mac":"98:DA:C4:6A:7A:6F","dev_name":"Smart Wi-Fi Plug With Energy Monitoring","alias":"wasmachine-meter","relay_state":1,"on_time":848,"active_mode":"none","feature":"TIM:ENE","updating":0,"icon_hash":"","rssi":-58,"led_off":0,"longitude_i":0,"latitude_i":0,"hwId":"044A516EE63C875F9458DA25C2CCC5A0","fwId":"00000000000000000000000000000000","deviceId":"8006AE9F636BDBC209B19AAB642877631BAAB2A9","oemId":"1998A14DAA86E4E001FD7CAF42868B5E","next_action":{"type":-1},"err_code":0}}}
2019-09-23 13:19:59,614:__main__:DEBUG:json_data: {'system': {'get_sysinfo': {'feature': 'TIM:ENE', 'led_off': 0, 'fwId': '00000000000000000000000000000000', 'type': 'IOT.SMARTPLUGSWITCH', 'rssi': -58, 'hw_ver': '2.0', 'next_action': {'type': -1}, 'on_time': 848, 'sw_ver': '1.5.4 Build 180815 Rel.121440', 'model': 'HS110(EU)', 'oemId': '1998A14DAA86E4E001FD7CAF42868B5E', 'icon_hash': '', 'active_mode': 'none', 'alias': 'wasmachine-meter', 'hwId': '044A516EE63C875F9458DA25C2CCC5A0', 'mac': '98:DA:C4:6A:7A:6F', 'deviceId': '8006AE9F636BDBC209B19AAB642877631BAAB2A9', 'relay_state': 1, 'dev_name': 'Smart Wi-Fi Plug With Energy Monitoring', 'err_code': 0, 'latitude_i': 0, 'updating': 0, 'longitude_i': 0}}}
2019-09-23 13:19:59,614:__main__:DEBUG:URL: http://192.168.2.1:8084/json.htm?type=command&param=udevice&idx=13&nvalue=1
2019-09-23 13:19:59,617:__main__:ERROR:HTTP error(None): None
As far as I can tell, something goes wrong with sending the values to domoticz. If I copy the url in a window (such as http://192.168.2.1:8084/json.htm?type=c ... 3&nvalue=1), it nicely updates the meter in domoticz. So far so good. However, when executing the script it doesn't work. Any ideas?

I also pasted this script in domoticz events and get the following output in the log of domoticz:

2019-09-24 16:37:27.557 Error: EventSystem: Failed to execute python event script "ajay100python3"
2019-09-24 16:37:27.557 Error: EventSystem: Traceback (most recent call last):
2019-09-24 16:37:27.557 Error: EventSystem: File "<string>", line 49, in <module>
2019-09-24 16:37:27.557 Error: EventSystem: NameError: name '__file__' is not defined

Any ideas anyone?
Last edited by jaaap on Tuesday 24 September 2019 16:38, edited 1 time in total.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest