TP-Link smart plug HS100/HS110

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

Moderator: leecollings

Post Reply
ollebull
Posts: 3
Joined: Saturday 10 October 2015 10:06
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: TP-Link smart plug HS100/HS110

Post by ollebull »

Hi, i'm running Domoticz on a Windows machine can i still run this script so that i can control and read from HS110.
I saw for instance this line in your py-script " domain="http://rpi3:8080/" ", since i'm not a programmer i'm not sure how to replace this
for a windows machine, and if there more places that could be affected.
regards Ollebull
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 ollebull,

If you are running Domoticz on your Windows machine, have a look at your browser address bar to see how you are accessing Domoticz. It might be something like http://127.0.0.1:8080 or http://192.168.0.1:8080. Whatever is there, that's what you use for the domain= variable (with the trailing slash (/)) in the python script.

You need to have Python installed on your Windows PC, as Domoticz doesn't do that for you. This HS1xx script uses Python version 2, not version 3 (they are a little incompatible).

The way to check if you have python installed is to go to a command prompt (windows key-R, or Start -> run then type cmd) and then type python at the prompt. If you get a response rather than an error (such as ''python is not recognized as an internal or external command, operable program or batch file.") then you have python installed. The response will tell you which version is installed (2.x or 3.x).

If you need to install python, you can start with 'Windows x86 MSI installer' from https://www.python.org/downloads/windows/ (click the link 'Latest Python 2 Release - Python 2.7.xx'). Apparently Domoticz works best with the x86 version (not 64 bit).

Once you get to that point, your Windows PC should work as well as a linux box for python scripting. In the following post, you can see how the commands work: viewtopic.php?t=17391#p132472 but use .bat instead of .cmd.

This may be a bridge too far if you don't have a little experience with command prompts, etc. on Windows. I hope it helps.

Cheers - Andrew
Marco31
Posts: 4
Joined: Friday 07 September 2018 17:00
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: TP-Link smart plug HS100/HS110

Post by Marco31 »

Hello,
I've installed Domoticz on a raspberry to record the power consumption history with a HS-110.
I've successfully added the device to the dashboard and I'm able to control it
I have 2 questions about the data recovery :
1 - I don't understand how the "Virtual sensors" are linked to the hardware IP adress. I've simply added the idx of the sensors to the editable variables section of the script, but all the sensors are in red. Perhaps that's due to the script error return code?

2 - I get an error when I run the script with the energy option :

Code: Select all

pi@raspberrypi:/home/marc/domoticz/scripts/python$ ./tplink_hs110_1.py -c energy
Traceback (most recent call last):
  File "./tplink_hs110_1.py", line 238, in <module>
    hs.read_hs110()
  File "./tplink_hs110_1.py", line 224, in read_hs110
    self.send_json(received_data)
  File "./tplink_hs110_1.py", line 155, in send_json
    voltage = round(float(json_data['emeter']['get_realtime']['voltage_mv']) / 1000,2)
KeyError: 'voltage_mv'
The info option works fine :

Code: Select all

pi@raspberrypi:/home/marc/domoticz/scripts/python$ ./tplink_hs110_1.py -c info
Sent:      {"system":{"get_sysinfo":{}}}
Received:  {"system":{"get_sysinfo":{"err_code":0,"sw_ver":"1.2.5 Build 180410 Rel.182657","hw_ver":"1.0","type":"IOT.SMARTPLUGSWITCH","model":"HS110(FR)","mac":"50:C7:BF:08:68:15","deviceId":"800643B60A0A5AA51473F47BFFD9E3FA1781ED98","hwId":"797CB3D09D9A83B1C43A623C6DD103C2","fwId":"00000000000000000000000000000000","oemId":"0D13F703F04C040DC3D27DB248C01A1A","alias":"My 1st Smart Plug","dev_name":"Wi-Fi Smart Plug With Energy Monitoring","icon_hash":"","relay_state":1,"on_time":17765,"active_mode":"schedule","feature":"TIM:ENE","updating":0,"rssi":-64,"led_off":0,"latitude":43.779649,"longitude":1.399550}}}
The generated debug shows that the values are correctly gathered :

Code: Select all

pi@raspberrypi:/home/marc/domoticz/scripts/python$ tail -4 hs110-1.log
2018-09-07 17:01:25,730:__main__:INFO:hs110-1 version 0.5 has started...
2018-09-07 17:01:25,777:__main__:DEBUG:Command: {"emeter":{"get_realtime":{}}}
2018-09-07 17:01:25,803:__main__:DEBUG:Sent:     {"emeter":{"get_realtime":{}}}
2018-09-07 17:01:25,805:__main__:DEBUG:Received: {"emeter":{"get_realtime":{"current":0.644156,"voltage":230.228466,"power":80.957878,"total":0.262000,"err_code":0}}}
pi@raspberrypi:/home/marc/domoticz/scripts/python$ more tplink_hs110_1.py 
#!/usr/bin/env python2
Also, here it is the config section of the script :

Code: Select all

...
# Begin user editable variables
version = 0.5
logger_name = "hs110-1"  #used for log file names, messages, etc
debug_level="DEBUG"  # debug options DEBUG, INFO, WARNING, ERROR, CRITICAL
delay_time = 15 #update time in seconds
domain="http://rpi3:8080/"
base_url = domain + "json.htm?type=command&param=udevice&nvalue=0"
monitor_list = ["voltage","current","power","usage"]
domoticz_idx = [1,2,3,5]
hs110_ip = "192.168.1.64"
text_logging = True
track_state = True
hs110_switch_idx = 4
datafile_columns = "Time,Voltage,Current,Power (W),Usage (kWHr)"
dailyfile_columns = "Date-Time,Usage (kWHr)"
# End user editable variables
....
Does someone have an idea please?
Thanks in advance.
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 Marco31,

It looks like you are really close to getting it working!
1 - I don't understand how the "Virtual sensors" are linked to the hardware IP adress. I've simply added the idx of the sensors to the editable variables section of the script, but all the sensors are in red. Perhaps that's due to the script error return code?
The hardware IP address (hs110_ip variable) is used when reading or 'commanding' the HS110. There is no connection between the hardware IP and the Domoticz device indexes. What you have done in the config section looks fine, assuming your Domoticz URL is on http://rpi3:8080/. You are correct in assuming that the red devices in Domoticz are a result of the error you are seeing when running the script directly.
2 - I get an error when I run the script with the energy option :
Can you check that the tplink_hs110_1.py file has UNIX style line endings, which should be LF (Line Feed) only, not CRLF (Carriage Return Line Feed)? I am using Notepad++ and when I click the 'Show all characters' button, I can see the line endings. To convert in Notepad++, choose Edit -> EOL Conversion -> UNIX/OSX format.

The other issue I came up against was having TABS in the file instead of spaces, particularly in the

Code: Select all

commands = {
        'info'     : '{"system":{"get_sysinfo":{}}}',
        'on'       : '{"system":{"set_relay_state":{"state":1}}}',
        'off'      : '{"system":{"set_relay_state":{"state":0}}}',
        'led_on'   : '{"system":{"set_led_off":{"off":0}}}',
        'led_off'  : '{"system":{"set_led_off":{"off":1}}}',
        'state'    : '{"system":{"get_sysinfo":{}}}',
        'cloudinfo': '{"cnCloud":{"get_info":{}}}',
        'wlanscan' : '{"netif":{"get_scaninfo":{"refresh":0}}}',
        'time'     : '{"time":{"get_time":{}}}',
        'schedule' : '{"schedule":{"get_rules":{}}}',
        'countdown': '{"count_down":{"get_rules":{}}}',
        'antitheft': '{"anti_theft":{"get_rules":{}}}',
        'reboot'   : '{"system":{"reboot":{"delay":1}}}',
        'reset'    : '{"system":{"reset":{"delay":1}}}',
        'energy'   : '{"emeter":{"get_realtime":{}}}'
    }
section.

If you copied the script directly from GitHub, it will depend on how you pasted/saved the script to the RPi as to whether these formatting errors may be an issue. BTW, I do my editing using FileZilla between the RPi and Notepad++ on a Windows 10 laptop.

Cheers - Andrew
Marco31
Posts: 4
Joined: Friday 07 September 2018 17:00
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: TP-Link smart plug HS100/HS110

Post by Marco31 »

Hi Andrew,
Many thanks for your reply. Unfortunately, I've checked all the points you've highlighted but still no success :-(
For the Url section, I didn't modified it as I wasn't sure that it was useful. Now its set to "http://192.168.1.253:8080" which is the working Domoticz URL (tested with my laptop).
Also, I've followed the notepad++ instructions you've provided (make sense as I was in the situation where CRLF and now it's only LF.
I get exactly the same behavior than before.
Do you have anymore ideas please?
Thanks.

Cheers.

Marc
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 Marc,

I'm not a Python expert by any means but I will have a go. There's a good tutorial on KeyError here: https://airbrake.io/blog/python-excepti ... n-keyerror
the KeyError is raised when accessing an invalid key within a dict.
The dict setup for us is the code below, so we can be fairly sure the problem is in that area.

Code: Select all

    commands = {
        'info'     : '{"system":{"get_sysinfo":{}}}',
        'on'       : '{"system":{"set_relay_state":{"state":1}}}',
        'off'      : '{"system":{"set_relay_state":{"state":0}}}',
        'led_on'   : '{"system":{"set_led_off":{"off":0}}}',
        'led_off'  : '{"system":{"set_led_off":{"off":1}}}',
        'state'    : '{"system":{"get_sysinfo":{}}}',
        'cloudinfo': '{"cnCloud":{"get_info":{}}}',
        'wlanscan' : '{"netif":{"get_scaninfo":{"refresh":0}}}',
        'time'     : '{"time":{"get_time":{}}}',
        'schedule' : '{"schedule":{"get_rules":{}}}',
        'countdown': '{"count_down":{"get_rules":{}}}',
        'antitheft': '{"anti_theft":{"get_rules":{}}}',
        'reboot'   : '{"system":{"reboot":{"delay":1}}}',
        'reset'    : '{"system":{"reset":{"delay":1}}}',
        'energy'   : '{"emeter":{"get_realtime":{}}}'
    }
TABS show as (->) and spaces as dots (.) when Show all Characters is turned on in Notepad++. I also have the Tab Settings set as 'Replace by space' in Notepad++ Preferences, so that TABs are not automatically added. If you checked and there are no TABS in this section instead of spaces, we need to debug a bit further.

Firstly I would try pasting the above dict code block directly over yours, just in case you are missing a minor formatting issue.

If that doesn't help, we can add an extra debugging line after json_data = (my line 146) to see what is coming through:

Code: Select all

    json_data = json.loads(received_data)
    logger.debug("json_data: {}".format(json_data))
I see you have debug_level="DEBUG", which is the best option for catching problems. In addition to any error that may appear in the console, we can also look at the log file, as you have done. It is saved in the same folder as the program. (in my case HS110-1.log). For one power logging circuit, mine shows the following:
2018-09-15 11:53:23,780:__main__:DEBUG:Command: {"emeter":{"get_realtime":{}}}
2018-09-15 11:53:23,885:__main__:DEBUG:Sent: {"emeter":{"get_realtime":{}}}
2018-09-15 11:53:23,886:__main__:DEBUG:Received: {"emeter":{"get_realtime":{"voltage_mv":242153,"current_ma":14,"power_mw":0,"total_wh":2,"err_code":0}}}
2018-09-15 11:53:23,887:__main__:DEBUG:json_data: {u'emeter': {u'get_realtime': {u'total_wh': 2, u'current_ma': 14, u'power_mw': 0, u'voltage_mv': 242153, u'err_code': 0}}}
2018-09-15 11:53:23,887:__main__:DEBUG:IDX: 90, Item: voltage, Value: 242.15
2018-09-15 11:53:23,888:__main__:DEBUG:URL: http://rpi3:8080/json.htm?type=command& ... lue=242.15
2018-09-15 11:53:23,895:__main__:DEBUG:IDX: 91, Item: current, Value: 0.01
2018-09-15 11:53:23,896:__main__:DEBUG:URL: http://rpi3:8080/json.htm?type=command& ... value=0.01
2018-09-15 11:53:23,903:__main__:DEBUG:IDX: 108, Item: power, Value: 0.0
2018-09-15 11:53:23,904:__main__:DEBUG:URL: http://rpi3:8080/json.htm?type=command& ... svalue=0.0
2018-09-15 11:53:23,910:__main__:DEBUG:IDX: 93, Items: Power (W), Usage (kWhr), Values: 0.0;0.002
2018-09-15 11:53:23,911:__main__:DEBUG:URL: http://rpi3:8080/json.htm?type=command& ... ue=0.0;2.0
There's nothing plugged in, so the current and power readings are very low.

Also note my software and hardware versions are different from yours, which could suggest different firmware, although I'm a bit unsure about the dates (mine looks earlier):
2018-09-15 11:53:08,757:__main__:DEBUG:Received: {"system":{"get_sysinfo":{"sw_ver":"1.2.10 Build 170828 Rel.104625","hw_ver":"2.0","type":"IOT.SMARTPLUGSWITCH","model":"HS110(AU)","mac":"xx:84:C6:3D:C0:xx","dev_name":"Smart Wi-Fi Plug With Energy Monitoring","alias":"TP-Link HS110 #1","relay_state":1,"on_time":5894,"active_mode":"none","feature":"TIM:ENE","updating":0,"icon_hash":"","rssi":-70,"led_off":0,"longitude_i":xx,"latitude_i":xx,"hwId":"A28C8BB92AFCB6CAFB83A8C00145F7E2","fwId":"00000000000000000000000000000000","deviceId":"8006B1553E3288EB95B589531A1EF88519FD5012","oemId":"6480C2101948463DC65D7009CAECDECC","err_code":0}}}
Good luck, I'm sure you're almost there! Please let us know either way.

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

Python3 version of the logger

Post by ajay100 »

I've just finished the Python3 version of the HS110 logger here https://github.com/ajay10000/TP-Link-HS110, with thanks to https://github.com/GadgetReactor/pyHS10 ... rotocol.py for the howto on the encryption and decryption routines.

Cheers - Andrew
Marco31
Posts: 4
Joined: Friday 07 September 2018 17:00
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: TP-Link smart plug HS100/HS110

Post by Marco31 »

Hello Andrew,
Sorry for my late feedback but I was on holydays 8-)
So, I've checked again all the script and text format but looks fine.
I've also created anew version of it but using your new Python v3 script and I have exactly same behaviors.
After a long long time spent to analyse the logs and tries, I think I've spotted the issue :
for any reason (perhas the hw/sw which are not exactly the same), the returned values are in decimal format whereas yours are Integrers :
Mine :

Code: Select all

2018-10-02 17:49:29,430:__main__:DEBUG:Received: {"emeter":{"get_realtime":{"current":0.414566,"voltage":230.421503,"power":49.656850,"total":2.304000,"err_code":0}}}
2018-10-02 17:49:29,433:__main__:DEBUG:json_data: {'emeter': {'get_realtime': {'voltage': [b]230.421503[/b], 'power': 49.65685, 'current': 0.414566, 'total': 2.304, 'err_code': 0}}}
Yours :

Code: Select all

018-09-15 11:53:23,887:__main__:DEBUG:json_data: {u'emeter': {u'get_realtime': {u'total_wh': 2, u'current_ma': 14, u'power_mw': 0, u'voltage_mv': [b]242153[/b], u'err_code': 0}}}
For example, if we look the voltage values, yours is 242153 millivolt whereas mine is 230.421503 volt.

I don't have found any related setting on the device itself.
I've tried to understand the code, but I'm not familiar with Python :roll: .
Could you please confirm if you feel that I'm on the right direction and so, if you can instruct me what lines of the code I need to modifiy?

Thanks a lot.
Cheers.

Marc
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 Marc,

That is a good pickup! It looks like your HS110 is returning the full values, which will simplify the code. We can try taking the division/rounding out and changing the key names as per what your unit is returning. Try changing these lines:

Code: Select all

voltage = round(float(json_data['emeter']['get_realtime']['voltage_mv']) / 1000,2)
current = round(float(json_data['emeter']['get_realtime']['current_ma']) / 1000,2)
power = round(float(json_data['emeter']['get_realtime']['power_mw']) / 1000,2)
usage = round(float(json_data['emeter']['get_realtime']['total_wh']) / 1000,3)
to this:

Code: Select all

voltage = float(json_data['emeter']['get_realtime']['voltage'])
current = float(json_data['emeter']['get_realtime']['current'])
power = float(json_data['emeter']['get_realtime']['power'])
usage = float(json_data['emeter']['get_realtime']['total'])
Hopefully that will do the trick.
Marco31
Posts: 4
Joined: Friday 07 September 2018 17:00
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: TP-Link smart plug HS100/HS110

Post by Marco31 »

Hi Andrew,
It worked like a charm :D
Thanks again for all your help.
Cheers.
Marc
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 »

That's great news Marc, thanks for letting us know.

Cheers - Andrew
cerocca
Posts: 7
Joined: Wednesday 22 November 2017 8:41
Target OS: Raspberry Pi / ODroid
Domoticz version: V 4.9700
Location: Italy
Contact:

Re: TP-Link smart plug HS100/HS110

Post by cerocca »

@ajay100 : I am trying to include my HS110 in my domoticz setup, so once find this thread I immediately tried it

unfortunately I am having similar (not the same) issues experienced by Marc :(
I created 4 devices (+ the switch, which I don't want to use) as in the attached screenshot, when I run the script I was getting same errors of Marc:

Code: Select all

pi@raspberrypi:~/domoticz/scripts/python $ python hs110.py -c energy
Traceback (most recent call last):
  File "hs110.py", line 238, in <module>
    hs.read_hs110()
  File "hs110.py", line 224, in read_hs110
    self.send_json(received_data)
  File "hs110.py", line 155, in send_json
    voltage = round(float(json_data['emeter']['get_realtime']['voltage_mv']) / 1000,2)
KeyError: 'voltage_mv'
also info option was giving me same results, the difference is in the log file where I cannot see values correctly gathered :

Code: Select all

pi@raspberrypi:~/domoticz/scripts/python $ tail -4 hs110-1a.log 
2018-10-16 20:04:06,081:__main__:DEBUG:Command: {"system":{"get_sysinfo":{}}}
2018-10-16 20:04:06,099:__main__:DEBUG:Sent:     {"system":{"get_sysinfo":{}}}
2018-10-16 20:04:06,101:__main__:DEBUG:Received: {"system":{"get_sysinfo":{"err_code":0,"sw_ver":"1.2.5 Build 171213 Rel.101523","hw_ver":"1.0","type":"IOT.SMARTPLUGSWITCH","model":"HS110(EU)","mac":"70:4F:57:1B:DB:37","deviceId":"800657AADA2A0C8635066D6ED760C98B18ECE692","hwId":"45E29DA8382494D2E82688B52A0B2EB5","fwId":"00000000000000000000000000000000","oemId":"3D341ECE302C0642C99E31CE2430544B","alias":"CiruPluggr","dev_name":"Wi-Fi Smart Plug With Energy Monitoring","icon_hash":"","relay_state":1,"on_time":786592,"active_mode":"schedule","feature":"TIM:ENE","updating":0,"rssi":-55,"led_off":0,"latitude":43.100680,"longitude":12.384625}}}
2018-10-16 20:04:06,103:__main__:DEBUG:URL: http://localhost:8080/json.htm?type=command&param=udevice&idx=107&nvalue=1
anyhow I tried to remove the division/rounding out and changing the key names as per your post of October the 3rd.
What I get is the following, my terminal is stuck:

Code: Select all

pi@raspberrypi:~/domoticz/scripts/python $ python hs110.py -c energy
^CTraceback (most recent call last):
  File "ahs.py", line 242, in <module>
    time.sleep(delay_time)
KeyboardInterrupt
No output! And of course only by CTRL+C I can stop the script.
But as you can also see from the screenshot, my domoticz seems to receive the data, but why I don't get an output from the terminal?
How can I have the script running "forever" without issues?
Maybe I misconfigured the devices in Domoticz?

Any help would be appreciated, thanks since now!
Attachments
Schermata 2018-10-16 alle 19.50.41.png
Schermata 2018-10-16 alle 19.50.41.png (41.68 KiB) Viewed 2898 times
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 cerocca,

Well done, you've got it working! Running in the looping mode, you will not see anything in the console and it will look like it's frozen. But you are getting the results in Domoticz, so that is good.

Now you can look at this post (if you haven't already done so) viewtopic.php?f=56&t=13290&p=188061&hilit=start#p188061 to see how I set mine up to start the script automatically at RPi startup. Then you don't need to type anything into the console unless you want to send a direct command (like switching the HS110 off and on, etc.)

Cheers - Andrew
cerocca
Posts: 7
Joined: Wednesday 22 November 2017 8:41
Target OS: Raspberry Pi / ODroid
Domoticz version: V 4.9700
Location: Italy
Contact:

Re: TP-Link smart plug HS100/HS110

Post by cerocca »

Hi ajay100 ,

thanks for the reply, glad to see that I have it working even without realizing it :D

I'll try ASAP the method you linked me to have the script running in loop, but may I ask you 3 further questions for my final/proper understanding?

1) why it is OK to don't see anything from the terminal? Did I "activate" the looping mode somehow in the script?
I ask this because if I check on your github page I understand that with the command

Code: Select all

python tplink_hs110.py -c energy
should give me an output on terminal. Am I wrong?

2) are my devices associated properly? The code from my python script is as follows:

Code: Select all

monitor_list = ["voltage","current","power","usage"]
domoticz_idx = [18,19,20,21]
Then I associated this list to my devices as per the screenshot I sent in my previous message. Is this correct?

3) is it needed to create the switch, or it can be omitted?

thanks for your support and above all for your nice work!
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 again cerocca,

1. Reading my original post, it wasn't as clear as it should have been, so I will fix that description in GitHub! The important sentence is
If 'energy' is used in the command line as above, the data is sent to Domoticz using JSON. If any other command is used, the switch will respond directly and show the result following the command.
.

So, the command

Code: Select all

python tplink_hs110.py -c energy
does activate the 'looping' mode as you say. It can be called from the console, but won't provide an output in the terminal, the results shown are actually from the logs. Except for testing, it is better run from a startup script.

Most of the other commands (other than 'energy') will provide a direct output in the terminal. i.e.

Code: Select all

python tplink_hs110.py -c off
(to turn the switch on) or

Code: Select all

python tplink_hs110.py -c info
(to get complete device information from the HS110).

2. From your Domoticz output, it looks like your hs_volt and hs_amp devices are correct, but you may have hs_elec and hs_usag around the wrong way. My kWh device is for usage and I am using a Custom Sensor for power (Watts). Swap 20 and 21 around where you are setting your index values and see if the results logged in Domoticz make sense. i.e.

Code: Select all

domoticz_idx = [18,19,21,20]
3. You can leave your code as it is and the switch will not be activated unless you send a command directly, such as

Code: Select all

python tplink_hs110.py -c on
.

It's great to get your feedback, thanks!

Andrew
cerocca
Posts: 7
Joined: Wednesday 22 November 2017 8:41
Target OS: Raspberry Pi / ODroid
Domoticz version: V 4.9700
Location: Italy
Contact:

Re: TP-Link smart plug HS100/HS110

Post by cerocca »

ajay100,

Thanks for your support, but I cannot get proper readings for usage and power, which is my main scope us using the HS110 in my domoticz setup.
Would you be so kind to tell me exactly how you create these devices?
I mean, from "hardware" tab, which kind of virtual sensors you create (and which idx do they correspond in your code) ?
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 @cerocca,

My HS110 hardware type in Domoticz is: Dummy (Does nothing, use for virtual switches only)
For these settings in code:

Code: Select all

monitor_list = ["voltage","current","power","usage"]
domoticz_idx = [90,91,108,93]
My Device settings in Domoticz are:
voltage, index 90 is Sensor type: Voltage. This shows as Type General, SubType Voltage
current, index 91 is Sensor type: Ampere (1 phase). This shows as Type General, SubType Current
power, index 108 is Custom Sensor, Sensor Type: Custom Sensor, Axis Label: Watts. This shows as Type General, SubType Custom Sensor
usage, index 93 is Sensor Type: Electric (Instant + Counter). This shows in the devices list as SubType kWh. It shows both power (watts) and usage (kWh).
usage, index 93 could also be Sensor Type: Counter Incremental (see EDIT below), as shown below. I've only just tried that one!

Cheers - Andrew

[EDIT] Counter Incremental doesn't look right for this purpose. I'm trying Counter now.
Attachments
HS110 power.jpg
HS110 power.jpg (14.09 KiB) Viewed 2853 times
HS110 usage.jpg
HS110 usage.jpg (11.77 KiB) Viewed 2853 times
Last edited by ajay100 on Saturday 20 October 2018 0:43, edited 1 time in total.
vamp
Posts: 34
Joined: Saturday 06 October 2018 13:20
Target OS: Linux
Domoticz version:
Contact:

Re: TP-Link smart plug HS100/HS110

Post by vamp »

Hi there,

This plugin work with HS100?

https://github.com/dahallgren/domoticz-tplink-smartplug

It is a on/off plugin, or show the energy usage?

somebody able to test it?
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 @vamp, it looks like it does both from the code. I don't have an HS100 to test, but I will try it with the HS110 when I can get some time.

Cheers - Andrew
vamp
Posts: 34
Joined: Saturday 06 October 2018 13:20
Target OS: Linux
Domoticz version:
Contact:

Re: TP-Link smart plug HS100/HS110

Post by vamp »

ajay100 wrote: Thursday 18 October 2018 15:23 Hi @vamp, it looks like it does both from the code. I don't have an HS100 to test, but I will try it with the HS110 when I can get some time.

Cheers - Andrew
I will be glad if you able to test it! I will plan to buy some and it will be good if they work with domoticz without any modification (firmware update, scripting, etc...)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest