Python Plugin: Samsung TV

Python and python framework

Moderator: leecollings

Post Reply
denman091
Posts: 30
Joined: Monday 31 July 2017 15:22
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Location: Pijnacker
Contact:

Re: Python Plugin: Samsung TV

Post by denman091 »

Jostice wrote: Thursday 14 December 2017 22:58
denman091 wrote: Thursday 14 December 2017 22:51
I have exactly the same problem.
Do you you have it already fixed?
Yes, check the forum post right after that one! There is the solution.
so, first you have downgrade samsungctl to version 0.6.0, right?
How dit you did that?

and then everything works with commandline but not in domoticz, right? therefore you have moved six.py to the right directory?
and then everything should work from command line and domoticz?
Jostice
Posts: 6
Joined: Monday 20 November 2017 21:24
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Samsung TV

Post by Jostice »

I am not sure if the downgrade was necessary, but the six.py is! If not installed then do that, or move from different python folder.

To downgrade: do an install remove of samsungctl
Then again do install samsungctl with pip but add the version number! I can't remember how, but Google is your friend....
denman091
Posts: 30
Joined: Monday 31 July 2017 15:22
Target OS: Raspberry Pi / ODroid
Domoticz version: 3.8153
Location: Pijnacker
Contact:

Re: Python Plugin: Samsung TV

Post by denman091 »

Jostice wrote: Friday 15 December 2017 18:03 I am not sure if the downgrade was necessary, but the six.py is! If not installed then do that, or move from different python folder.
I have copied the six.py file.
But when i "Enable the hardware in domticz i get the following error in the log:
2017-12-20 22:17:53.514 (Samsung TV) No ini file :/home/pi/domoticz/plugins/SamsungTV/plugin_remote_6.ini

Also when i try to connect via command line i still get the error: Connection Refushed.
zak45
Posts: 952
Joined: Sunday 22 January 2017 11:37
Target OS: Windows
Domoticz version: V2024.4
Contact:

Re: Python Plugin: Samsung TV

Post by zak45 »

denman091 wrote: Wednesday 20 December 2017 22:20
But when i "Enable the hardware in domticz i get the following error in the log:
2017-12-20 22:17:53.514 (Samsung TV) No ini file :/home/pi/domoticz/plugins/SamsungTV/plugin_remote_6.ini

Also when i try to connect via command line i still get the error: Connection Refushed.
you're in Debug mode, this not indicate error, only the fact that custom command for Remote is not managed.

The first time you send a command, you should aknowledge on your TV.
dextm80
Posts: 117
Joined: Tuesday 24 October 2017 18:32
Target OS: Linux
Domoticz version: 4.10159
Contact:

Re: Python Plugin: Samsung TV

Post by dextm80 »

It’s more difficult for a normal or newbie user install that plugin whitout a definitive simple guide....this is what i think.

I abandoned this project for now :(
Domoticz on AsRock j3455-ITX 8gb ram - Aeotec ZWave Usb Stick - RFLink 433Mhz
1x Fibaro Wall Plug
1x Fibaro Motion Sensor
x NeoCoolcam Wall Plug
Netatmo Weather Station - Netatmo Thermostat
Philips Hue Bridge
desertdog
Posts: 84
Joined: Sunday 14 August 2016 13:45
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.1
Location: Netherlands
Contact:

Re: Python Plugin: Samsung TV

Post by desertdog »

zak45 wrote: Wednesday 20 December 2017 22:39
denman091 wrote: Wednesday 20 December 2017 22:20
But when i "Enable the hardware in domticz i get the following error in the log:
2017-12-20 22:17:53.514 (Samsung TV) No ini file :/home/pi/domoticz/plugins/SamsungTV/plugin_remote_6.ini

Also when i try to connect via command line i still get the error: Connection Refushed.
you're in Debug mode, this not indicate error, only the fact that custom command for Remote is not managed.

The first time you send a command, you should aknowledge on your TV.
I think I might have missed that notification on my tv. It might have been there but I never saw it or looked at the tv at that time. At least the tv is not showing a confirmation screen (anymore). Is there a way to get this screen again on the tv?
timberwolf
Posts: 5
Joined: Wednesday 27 December 2017 9:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Samsung TV

Post by timberwolf »

One more installation problem...

I have got the plugin working from the command line. In the hardware list i can add the Samsung TV, but i don't get any settings fields.

When i add the hardware i get this in the log:

Code: Select all

2017-12-30 11:07:42.967 Error: () failed to load 'plugin.py', Python Path used was ':/usr/lib/python3.4/:/usr/lib/python3.4/plat-arm-linux-gnueabihf:/usr/lib/python3.4/lib-dynload'.
2017-12-30 11:07:42.967 Error: (tv) Module Import failed, exception: 'ImportError'
2017-12-30 11:07:42.967 Error: (tv) Module Import failed: ' Name: samsungctl'
2017-12-30 11:07:42.967 Error: (tv) Error Line details not available.
2017-12-30 11:09:00.867 Error: tv hardware (4) thread seems to have ended unexpectedly
I have spent two days on this now reading everything i can find, but no luck. I guess it's just some stupid misstake, but i just can't find it.

Running Domoticz (Version: 3.8797)on a Raspberry Pi.
dextm80
Posts: 117
Joined: Tuesday 24 October 2017 18:32
Target OS: Linux
Domoticz version: 4.10159
Contact:

Re: Python Plugin: Samsung TV

Post by dextm80 »

Same problem, because there isn t a clear guide unfortunately
Domoticz on AsRock j3455-ITX 8gb ram - Aeotec ZWave Usb Stick - RFLink 433Mhz
1x Fibaro Wall Plug
1x Fibaro Motion Sensor
x NeoCoolcam Wall Plug
Netatmo Weather Station - Netatmo Thermostat
Philips Hue Bridge
zak45
Posts: 952
Joined: Sunday 22 January 2017 11:37
Target OS: Windows
Domoticz version: V2024.4
Contact:

Re: Python Plugin: Samsung TV

Post by zak45 »

@timberwolf
this is due to the fact you have more than one python version on your system.
if you take a look at your error :

2017-12-30 11:07:42.967 Error: (tv) Module Import failed, exception: 'ImportError'
2017-12-30 11:07:42.967 Error: (tv) Module Import failed: ' Name: samsungctl

python could not find your samsungctl module. you need to copy it under one of these directories:

/usr/lib/python3.4/:/usr/lib/python3.4/plat-arm-linux-gnueabihf:/usr/lib/python3.4/lib-dynload'.

Some others even copy it under the plugin directory, but I would avoid to do that.

All of that depend of your OS and python installation, this need to be adapted to your installation.
Calzor Suzay
Posts: 145
Joined: Tuesday 08 July 2014 15:10
Target OS: -
Domoticz version: 4.9700
Location: UK
Contact:

Re: Python Plugin: Samsung TV

Post by Calzor Suzay »

Having issues getting this working :(

On a Raspberry Pi at the basic samsungctl level I can't get the command like to work.
I have a KS7000 which has been mentioned in this thread as working but get

samsungctl -i --host 192.168.1.42 --method websocket
Error: Operation now in progress

I tried a port scan and 8000, 8001, 8002 are listening so tried

samsungctl -i --host 192.168.1.42 --port 8000 --method websocket
Error: Operation now in progress

Any ideas?

The next stage is getting plugin.py working which I think it is as it's in the log trying to talk to it and says

(SamsungTV) Calling message handler 'onHeartbeat'.
(SamsungTV) Device has disconnected - Maybe PowerOff

From the supported models it has
Series K Yes Socket Tizen 2016
Implying I need websocket but when I try it without I get

samsungctl -i --host 192.168.1.42 --port 8000
Error: Connection closed!
samsungctl -i --host 192.168.1.42 --port 8001
Error: Connection closed!
samsungctl -i --host 192.168.1.42 --port 8002
Error: Connection closed!
samsungctl -i --host 192.168.1.42 --port 8003
Error: Connection refused
samsungctl -i --host 192.168.1.42 --port 8005
Error: Connection refused

Is there anything I need to turn on via the tv, it never pops up and prompts for anything.
dextm80
Posts: 117
Joined: Tuesday 24 October 2017 18:32
Target OS: Linux
Domoticz version: 4.10159
Contact:

Re: Python Plugin: Samsung TV

Post by dextm80 »

same problem, i ve ks7000 too
Domoticz on AsRock j3455-ITX 8gb ram - Aeotec ZWave Usb Stick - RFLink 433Mhz
1x Fibaro Wall Plug
1x Fibaro Motion Sensor
x NeoCoolcam Wall Plug
Netatmo Weather Station - Netatmo Thermostat
Philips Hue Bridge
Calzor Suzay
Posts: 145
Joined: Tuesday 08 July 2014 15:10
Target OS: -
Domoticz version: 4.9700
Location: UK
Contact:

Re: Python Plugin: Samsung TV

Post by Calzor Suzay »

Ok managed to get it further...

I have it working via the command line but specify a port, in my case 8001 and have to add a timeout option, even 1 works, so...

samsungctl -i --host 192.168.1.42 --port 8001 --method websocket --timeout 1

Brings me up a menu from a quick test can send commands.
Also in the network settings in the TV there's something called Mobile Device Manager, I have access notification to off so it lets devices in, this was off anyway as I already had an app controlling the tv and can see, mine, my wifes and the iPad listed here.

I transferred the options over to Domoticz, it sees the tv 'alive' but now have this problem

2017-12-31 19:35:17.480 (SamsungTV) isAlive status :True
2017-12-31 19:35:17.480 (SamsungTV) Devices are connected - Initialisation
2017-12-31 19:35:17.482 Error: (SamsungTV) 'onStart' failed 'ImportError'.
2017-12-31 19:35:17.482 Error: (SamsungTV) ----> Line 134 in /home/osmc/domoticz/plugins/SamsungTV/plugin.py, function onStart
2017-12-31 19:35:17.482 Error: (SamsungTV) ----> Line 287 in /home/osmc/domoticz/plugins/SamsungTV/plugin.py, function SamsungSend
2017-12-31 19:35:17.482 Error: (SamsungTV) ----> Line 10 in /usr/lib/python3.4/samsungctl/remote.py, function __init__
2017-12-31 19:35:17.482 Error: (SamsungTV) ----> Line 13 in /usr/lib/python3.4/samsungctl/remote_websocket.py, function __init__
2017-12-31 19:35:17.482 (SamsungTV) Heartbeat interval set to: 15.

It obviously creates no devices and fails, any ideas?
zak45
Posts: 952
Joined: Sunday 22 January 2017 11:37
Target OS: Windows
Domoticz version: V2024.4
Contact:

Re: Python Plugin: Samsung TV

Post by zak45 »

@Calzor Suzay
All of that is related to python and depend of your OS and installation/version.
if the command line is working, that's great, this mean you should have all requirement in place.
Now, if this not work in the Domoticz python framework, this is mainly due to the fact that the framework do not search in the right directory for your system and you need to help it to find the module by copying it.
For your television, you need websocket-client installed and to found where you have installed it, just do this command:
sudo pip3 show websocket-client

this should give you this output ( take care , this is only example from my system)

---
Metadata-Version: 2.0
Name: websocket-client
Version: 0.46.0
Summary: WebSocket client for python. hybi13 is supported.
Home-page: https://github.com/websocket-client/web ... client.git
Author: liris
Author-email: [email protected]
Installer: pip
License: LGPL
Location: /usr/local/lib/python3.5/dist-packages
Requires: six
Classifiers:
Development Status :: 4 - Beta
License :: OSI Approved :: GNU Library or Lesser General Public License (LGPL)
Programming Language :: Python
Programming Language :: Python :: 2
Programming Language :: Python :: 3
Operating System :: MacOS :: MacOS X
Operating System :: POSIX
Operating System :: Microsoft :: Windows
Topic :: Internet

Here, you can see that this has been installed under /usr/local/lib/python3.5/dist-packages
You need to copy it from this directory(websocket) under the directory you have already copy samsungctl.
Take care also for the python module dependencies; here your can see that this requires "six", so do the same for this module if necessary.
timberwolf
Posts: 5
Joined: Wednesday 27 December 2017 9:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Samsung TV

Post by timberwolf »

zak45 wrote: Sunday 31 December 2017 0:01 @timberwolf
this is due to the fact you have more than one python version on your system.
if you take a look at your error :

2017-12-30 11:07:42.967 Error: (tv) Module Import failed, exception: 'ImportError'
2017-12-30 11:07:42.967 Error: (tv) Module Import failed: ' Name: samsungctl

python could not find your samsungctl module. you need to copy it under one of these directories:

/usr/lib/python3.4/:/usr/lib/python3.4/plat-arm-linux-gnueabihf:/usr/lib/python3.4/lib-dynload'.

Some others even copy it under the plugin directory, but I would avoid to do that.

All of that depend of your OS and python installation, this need to be adapted to your installation.
So i copied the samsungctl to the suggested directories and the initial error disappeared. Now i get this error instead when i try to add the Samsung TV hardware:

Code: Select all

2018-01-03 12:09:48.985 Error: () failed to load 'plugin.py', Python Path used was ':/usr/lib/python3.4/:/usr/lib/python3.4/plat-arm-linux-gnueabihf:/usr/lib/python3.4/lib-dynload'.
2018-01-03 12:09:48.985 Error: (TV) Module Import failed, exception: 'ImportError'
2018-01-03 12:09:48.985 Error: (TV) Module Import failed: ' Name: plugin'
2018-01-03 12:09:48.986 Error: (TV) Error Line details not available.
if i copy module.py to /usr/lib/python3.4/ i get these errors instead:

Code: Select all

2018-01-03 12:17:17.466 Error: Initialise: Error 'Error document empty.' at line 0 column 0 in XML ''.
2018-01-03 12:17:17.478 Error: (TV) 'onStart' failed 'ValueError':'invalid literal for int() with base 10: '''.
2018-01-03 12:17:17.478 Error: (TV) ----> Line 124 in /usr/lib/python3.4/plugin.py, function onStart
2018-01-03 12:17:26.994 Error: (TV) 'onHeartbeat' failed 'NameError'.
2018-01-03 12:17:26.994 Error: (TV) ----> Line 205 in /usr/lib/python3.4/plugin.py, function onHeartbeat
2018-01-03 12:17:26.994 Error: (TV) ----> Line 330 in /usr/lib/python3.4/plugin.py, function isAlive
2018-01-03 12:17:41.977 Error: (TV) 'onHeartbeat' failed 'NameError'.
2018-01-03 12:17:41.978 Error: (TV) ----> Line 205 in /usr/lib/python3.4/plugin.py, function onHeartbeat
2018-01-03 12:17:41.978 Error: (TV) ----> Line 330 in /usr/lib/python3.4/plugin.py, function isAlive
Still no luck...
zak45
Posts: 952
Joined: Sunday 22 January 2017 11:37
Target OS: Windows
Domoticz version: V2024.4
Contact:

Re: Python Plugin: Samsung TV

Post by zak45 »

timberwolf wrote: Wednesday 03 January 2018 12:18 So i copied the samsungctl to the suggested directories and the initial error disappeared. Now i get this error instead when i try to add the Samsung TV hardware:

Code: Select all

2018-01-03 12:09:48.985 Error: () [b]failed to load 'plugin.py'[/b], Python Path used was ':/usr/lib/python3.4/:/usr/lib/python3.4/plat-arm-linux-gnueabihf:/usr/lib/python3.4/lib-dynload'.
2018-01-03 12:09:48.985 Error: (TV) Module Import failed, exception: 'ImportError'
2018-01-03 12:09:48.985 Error: (TV) Module Import failed: ' Name: plugin'
2018-01-03 12:09:48.986 Error: (TV) Error Line details not available.
if i copy module.py to /usr/lib/python3.4/ i get these errors instead:
1: plugin.py do not exist on the plugin directory, you need to have it there.
2:do not know what is "module.py" ???? and not necessary for this plugin.
timberwolf
Posts: 5
Joined: Wednesday 27 December 2017 9:41
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Python Plugin: Samsung TV

Post by timberwolf »

zak45 wrote: Wednesday 03 January 2018 13:35
timberwolf wrote: Wednesday 03 January 2018 12:18 So i copied the samsungctl to the suggested directories and the initial error disappeared. Now i get this error instead when i try to add the Samsung TV hardware:

Code: Select all

2018-01-03 12:09:48.985 Error: () [b]failed to load 'plugin.py'[/b], Python Path used was ':/usr/lib/python3.4/:/usr/lib/python3.4/plat-arm-linux-gnueabihf:/usr/lib/python3.4/lib-dynload'.
2018-01-03 12:09:48.985 Error: (TV) Module Import failed, exception: 'ImportError'
2018-01-03 12:09:48.985 Error: (TV) Module Import failed: ' Name: plugin'
2018-01-03 12:09:48.986 Error: (TV) Error Line details not available.
if i copy module.py to /usr/lib/python3.4/ i get these errors instead:
1: plugin.py do not exist on the plugin directory, you need to have it there.
2:do not know what is "module.py" ???? and not necessary for this plugin.
Sorry, typing mistake, no module.py. The plugin.py does exist in the plugins directory:

Code: Select all

pi@raspberrypi:~/domoticz/plugins/samsungtv $ ls
plugin.py
pi@raspberrypi:~/domoticz/plugins/samsungtv $ 
BR

Timberwolf
zak45
Posts: 952
Joined: Sunday 22 January 2017 11:37
Target OS: Windows
Domoticz version: V2024.4
Contact:

Re: Python Plugin: Samsung TV

Post by zak45 »

@timberwolf
so check rights on the plugin.py and restart domoticz.
Calzor Suzay
Posts: 145
Joined: Tuesday 08 July 2014 15:10
Target OS: -
Domoticz version: 4.9700
Location: UK
Contact:

Re: Python Plugin: Samsung TV

Post by Calzor Suzay »

Ok this seems to kill Domoticz...

Restored my Raspberry Pi (OSMC) back to an image.
Ran through the install
sudo apt-get install python3-pip

Installing collected packages: samsungctl
Running setup.py install for samsungctl

Installing samsungctl script to /usr/local/bin
Successfully installed samsungctl

sudo pip3 install samsungctl

Installing collected packages: samsungctl
Running setup.py install for samsungctl

Installing samsungctl script to /usr/local/bin
Successfully installed samsungctl

sudo pip3 install websocket-client

Requirement already satisfied (use --upgrade to upgrade): six in /usr/lib/python3/dist-packages (from websocket-client)
Installing collected packages: websocket-client
Successfully installed websocket-client

Created folder /home/osmc/domoticz/plugins/samsungtv
copied plugin.py to it and set chmod 777

Tested from command line and works
samsungctl -i --host 192.168.1.42 --port 8001 --method websocket --timeout 1

Rebooted, was getting weird error and from comments on board then installed this which got rid of error (I'm on 3.8153)
Error "EventSystem - Python: Failed dynamic library load, install the latest libpython3.x library that is available for your platform."
sudo apt-get install python3-dev

Now no errors in log
Python EventSystem: Module not found - Trying to initialize.
Python EventSystem: Initalizing event module.
EventSystem: Started

Added hardware to Domoticz but have error
Error: (SamsungTV) failed to load 'plugin.py', Python Path used was '/home/osmc/domoticz/plugins/samsungtv/:/usr/lib/python3.4/:/usr/lib/python3.4/plat-arm-linux-gnueabihf:/usr/lib/python3.4/lib-dynload'.
Error: (SamsungTV) Module Import failed, exception: 'ImportError'
Error: (SamsungTV) Module Import failed: ' Name: samsungctl'

So copied samsungctl over
sudo cp -r /usr/local/lib/python3.4/dist-packages/samsungctl /usr/lib/python3.4/

Now get the following in the logs
Error: (SamsungTV) 'onStart' failed 'ImportError'.
Error: (SamsungTV) ----> Line 134 in /home/osmc/domoticz/plugins/samsungtv/plugin.py, function onStart
Error: (SamsungTV) ----> Line 287 in /home/osmc/domoticz/plugins/samsungtv/plugin.py, function SamsungSend
Error: (SamsungTV) ----> Line 10 in /usr/lib/python3.4/samsungctl/remote.py, function __init__
Error: (SamsungTV) ----> Line 13 in /usr/lib/python3.4/samsungctl/remote_websocket.py, function __init__

sudo cp -r /usr/local/lib/python3.4/dist-packages/websocket /usr/lib/python3.4/samsungctl

sudo cp ./six.py /usr/local/lib/python3.4/dist-packages

Still no luck with same last error
zak45
Posts: 952
Joined: Sunday 22 January 2017 11:37
Target OS: Windows
Domoticz version: V2024.4
Contact:

Re: Python Plugin: Samsung TV

Post by zak45 »

if you have done this :
sudo cp -r /usr/local/lib/python3.4/dist-packages/websocket /usr/lib/python3.4/samsungctl

this should have killed your samsungctl installation.
this should be :
sudo cp -r /usr/local/lib/python3.4/dist-packages/websocket /usr/lib/python3.4/websocket
Calzor Suzay
Posts: 145
Joined: Tuesday 08 July 2014 15:10
Target OS: -
Domoticz version: 4.9700
Location: UK
Contact:

Re: Python Plugin: Samsung TV

Post by Calzor Suzay »

I think that was a typo to be honest as samsungctl folder was still intact.

Didn't realise websocket needed to be in the folder above not samsungctl so running this below has got it working
sudo cp -r /usr/local/lib/python3.4/dist-packages/websocket /usr/lib/python3.4/websocket

Saying that I sent a few volume up commands then it kills Domoticz :(
Have to restart service

User: Admin initiated a switch command (85/SamsungTV - Volume/Set Level)
(SamsungTV) Calling message handler 'onCommand'.
(SamsungTV) onCommand called for Unit 3: Parameter 'Set Level', Level: 10, Connected: True
Error: (SamsungTV) 'onCommand' failed 'ValueError'.
Error: (SamsungTV) ----> Line 169 in /home/osmc/domoticz/plugins/samsungtv/plugin.py, function onCommand
Error: (SamsungTV) ----> Line 287 in /home/osmc/domoticz/plugins/samsungtv/plugin.py, function SamsungSend
Error: (SamsungTV) ----> Line 10 in /usr/lib/python3.4/samsungctl/remote.py, function __init__
Error: (SamsungTV) ----> Line 24 in /usr/lib/python3.4/samsungctl/remote_websocket.py, function __init__
Error: (SamsungTV) ----> Line 62 in /usr/lib/python3.4/samsungctl/remote_websocket.py, function _read_response
Error: (SamsungTV) ----> Line 318 in /usr/lib/python3.4/json/__init__.py, function loads
Error: (SamsungTV) ----> Line 343 in /usr/lib/python3.4/json/decoder.py, function decode
Error: (SamsungTV) ----> Line 361 in /usr/lib/python3.4/json/decoder.py, function raw_decode
(SamsungTV) Calling message handler 'onHeartbeat'.

About here the site falls over and I have to sudo service domoticz restart for it work again.
Post Reply

Who is online

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