Bless ya, well I appreciate your help!NickHead wrote:There is, but I aint done that yet, and wether it would work is another story.
You could always try entering other commands in to the text string to see if it changes channels/volume or whatever/
I simple read of about 10 bytes would suffice I would reckon.
i am doing too many things here at the moment , I have to rewrite my SolarPanel programs as well
not only that , I have to to work in a bit
Telnet Type Data to Domoticz Help Topic is solved
Moderator: leecollings
-
simon_rb
- Posts: 612
- Joined: Wednesday 07 August 2013 19:09
- Target OS: -
- Domoticz version:
- Location: UK
- Contact:
Re: Telnet Type Data to Domoticz Help
-
simon_rb
- Posts: 612
- Joined: Wednesday 07 August 2013 19:09
- Target OS: -
- Domoticz version:
- Location: UK
- Contact:
Telnet Type Data to Domoticz Help
And this
http://forum.micasaverde.com/index.php?topic=22950.15
Looks like response is PWON if on and PWSTANDBY if in standby.
http://forum.micasaverde.com/index.php?topic=22950.15
Looks like response is PWON if on and PWSTANDBY if in standby.
-
NickHead
- Posts: 83
- Joined: Tuesday 29 October 2013 18:30
- Target OS: Linux
- Domoticz version:
- Location: North East Coast of the UK
- Contact:
Re: Telnet Type Data to Domoticz Help
This is what I got up to now:
I have done a trial run and can get it to work with my Domoticz ( Emulating Denon Send/Requests )
I have done a trial run and can get it to work with my Domoticz ( Emulating Denon Send/Requests )
Code: Select all
#!/usr/bin/env python
import os
import sys
import socket
import urllib
DStart = " "
###############################################
# Denon Amp Settings
denon_host = "192.168.0.231" #IP of Denon Amp
denon_port = 8081 #Port of Denon Amp
###############################################
#domoticz settings
domoticz_host = '192.168.0.148' #IP of Domoticz
domoticz_port = '8080' #Port of Domoticz
domoticz_url = 'json.htm'
avr_switch = '379' #This Number is the same as the Device ID of the Switch
################################################
def SendInit_PW():
Text = "PW?"
s.send(Text)
def ReceiveData():
global DStart
while DStart != "P":
DStart = (s.recv(1)) # Wait for a response "Pxxx"
DStart = (s.recv(3)) # Get next 3 characters
if DStart == "WON":
print " Denon Power is ON"
Switch = ("http://" + domoticz_host + ":" + domoticz_port + "/" + domoticz_url + "?type=command¶m=switchlight&idx=" + avr_switch + "&switchcmd=On")
urllib.urlopen(Switch)
if DStart == "WST":
print "Denon Power is OFF"
Switch = ("http://" + domoticz_host + ":" + domoticz_port + "/" + domoticz_url + "?type=command¶m=switchlight&idx=" + avr_switch + "&switchcmd=Off")
urllib.urlopen(Switch)
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print " Socket successfully created"
except socket.error as err:
print" "
s.connect((denon_host,denon_port))
print " Host =",denon_host," Port = ",denon_port
print " Connecting to Denon Amplifier"
SendInit_PW()
ReceiveData()
A lot of stuff that is doing my head in.
-
simon_rb
- Posts: 612
- Joined: Wednesday 07 August 2013 19:09
- Target OS: -
- Domoticz version:
- Location: UK
- Contact:
Re: Telnet Type Data to Domoticz Help
Brilliant - Thanks.
Just saved the script and filled in the details and I got this when trying to run it (assuming I have ran it correctly)
UPDATE:- I added # -*- coding: utf-8 -*- to the top of the file, then it didn't like the " " for denon_host = "192.168.1.12" so changed to ' ' and got this:-
Just saved the script and filled in the details and I got this when trying to run it (assuming I have ran it correctly)
Code: Select all
File "/home/pi/domoticz/scripts/Denon_Airplay_Check.py", line 10
SyntaxError: Non-ASCII character '\xe2' in file /home/pi/domoticz/scripts/Denon_Airplay_Check.py on line 10, but no encoding declared; see http://www.python.org/peps/pep-0263.html for detailsCode: Select all
pi@raspberrypi ~ $ python /home/pi/domoticz/scripts/Denon_Airplay_Check.py
File "/home/pi/domoticz/scripts/Denon_Airplay_Check.py", line 11
denon_host = '192.168.1.12’ #IP of Denon Amp
^
SyntaxError: EOL while scanning string literal
Last edited by simon_rb on Monday 04 April 2016 1:06, edited 4 times in total.
-
NickHead
- Posts: 83
- Joined: Tuesday 29 October 2013 18:30
- Target OS: Linux
- Domoticz version:
- Location: North East Coast of the UK
- Contact:
Re: Telnet Type Data to Domoticz Help
mmm no error on line 10 is there ?>
A lot of stuff that is doing my head in.
-
NickHead
- Posts: 83
- Joined: Tuesday 29 October 2013 18:30
- Target OS: Linux
- Domoticz version:
- Location: North East Coast of the UK
- Contact:
Re: Telnet Type Data to Domoticz Help
Are you running it by
python Denon_Airplay_Check.py
???
if not , your doing it wrong
python Denon_Airplay_Check.py
???
if not , your doing it wrong
A lot of stuff that is doing my head in.
-
simon_rb
- Posts: 612
- Joined: Wednesday 07 August 2013 19:09
- Target OS: -
- Domoticz version:
- Location: UK
- Contact:
Re: Telnet Type Data to Domoticz Help
Got as far as this so far
Code: Select all
pi@raspberrypi ~ $ python /home/pi/domoticz/scripts/Denon_Airplay_Check.py
File "/home/pi/domoticz/scripts/Denon_Airplay_Check.py", line 27
while DStart != "P":
^
IndentationError: unexpected indent-
NickHead
- Posts: 83
- Joined: Tuesday 29 October 2013 18:30
- Target OS: Linux
- Domoticz version:
- Location: North East Coast of the UK
- Contact:
Re: Telnet Type Data to Domoticz Help
yer, python has to be perfect on indentations
maybe the cut/paste messed it up
maybe the cut/paste messed it up
A lot of stuff that is doing my head in.
-
NickHead
- Posts: 83
- Joined: Tuesday 29 October 2013 18:30
- Target OS: Linux
- Domoticz version:
- Location: North East Coast of the UK
- Contact:
Re: Telnet Type Data to Domoticz Help
Code: Select all
def ReceiveData():
global DStart
while DStart != "P":
DStart = (s.recv(1)) # Wait for a response "Pxxx"
DStart = (s.recv(3)) # Get next 3 characters
if DStart == "WON":
If its the same when i press enter
and it isnt
A lot of stuff that is doing my head in.
-
NickHead
- Posts: 83
- Joined: Tuesday 29 October 2013 18:30
- Target OS: Linux
- Domoticz version:
- Location: North East Coast of the UK
- Contact:
Re: Telnet Type Data to Domoticz Help
i'll attach it as a file
A lot of stuff that is doing my head in.
-
simon_rb
- Posts: 612
- Joined: Wednesday 07 August 2013 19:09
- Target OS: -
- Domoticz version:
- Location: UK
- Contact:
Re: Telnet Type Data to Domoticz Help
Got past that, Stuck on this now
Code: Select all
pi@raspberrypi ~ $ python /home/pi/domoticz/scripts/Denon_Airplay_Check.py
File "/home/pi/domoticz/scripts/Denon_Airplay_Check.py", line 30
if DStart == "WON":
^
IndentationError: unindent does not match any outer indentation level
-
NickHead
- Posts: 83
- Joined: Tuesday 29 October 2013 18:30
- Target OS: Linux
- Domoticz version:
- Location: North East Coast of the UK
- Contact:
Re: Telnet Type Data to Domoticz Help
wont let me do it for some reason
A lot of stuff that is doing my head in.
-
simon_rb
- Posts: 612
- Joined: Wednesday 07 August 2013 19:09
- Target OS: -
- Domoticz version:
- Location: UK
- Contact:
Re: Telnet Type Data to Domoticz Help
I'm half way through the code.. any ideas why the error above is there? Python is so temperamental lolNickHead wrote:wont let me do it for some reason
-
NickHead
- Posts: 83
- Joined: Tuesday 29 October 2013 18:30
- Target OS: Linux
- Domoticz version:
- Location: North East Coast of the UK
- Contact:
Re: Telnet Type Data to Domoticz Help
if Dstart != "P":
goes directly under DSTART == "WON"
all in the same line other then DSTART = (s.recv(1))
goes directly under DSTART == "WON"
all in the same line other then DSTART = (s.recv(1))
A lot of stuff that is doing my head in.
-
NickHead
- Posts: 83
- Joined: Tuesday 29 October 2013 18:30
- Target OS: Linux
- Domoticz version:
- Location: North East Coast of the UK
- Contact:
Re: Telnet Type Data to Domoticz Help
if there is a colon (:) then there is an indentation on the NEXT line
Python Program Rules
Python Program Rules
A lot of stuff that is doing my head in.
-
simon_rb
- Posts: 612
- Joined: Wednesday 07 August 2013 19:09
- Target OS: -
- Domoticz version:
- Location: UK
- Contact:
Re: Telnet Type Data to Domoticz Help
I have ran it in an online python editor and I get the same error. Can't figure it out lol
UPDATE:- It needed one more space - seems to have opened socket now..
UPDATE:- It needed one more space - seems to have opened socket now..
Last edited by simon_rb on Monday 04 April 2016 1:43, edited 1 time in total.
-
NickHead
- Posts: 83
- Joined: Tuesday 29 October 2013 18:30
- Target OS: Linux
- Domoticz version:
- Location: North East Coast of the UK
- Contact:
Re: Telnet Type Data to Domoticz Help
Sorry
if Dstart != "P":
goes directly under global DSTART
all in the same line other then DSTART = (s.recv(1))
I am Soooo tired now, so off to bed, will try again tomorrow
making too many errors now, I have been at work and knackud
if Dstart != "P":
goes directly under global DSTART
all in the same line other then DSTART = (s.recv(1))
I am Soooo tired now, so off to bed, will try again tomorrow
making too many errors now, I have been at work and knackud
A lot of stuff that is doing my head in.
-
NickHead
- Posts: 83
- Joined: Tuesday 29 October 2013 18:30
- Target OS: Linux
- Domoticz version:
- Location: North East Coast of the UK
- Contact:
Re: Telnet Type Data to Domoticz Help
if you can PM me, dont know wether its on, then send me an email and i'll send you the file.
should be in order then
gnite
should be in order then
gnite
A lot of stuff that is doing my head in.
-
simon_rb
- Posts: 612
- Joined: Wednesday 07 August 2013 19:09
- Target OS: -
- Domoticz version:
- Location: UK
- Contact:
Re: Telnet Type Data to Domoticz Help
Don't be sorry, I'm off to be now too - up at 6. I have it running now but it doesn't do anything after it says connecting to denon.NickHead wrote: I am Soooo tired now, so off to bed, will try again tomorrow
making too many errors now, I have been at work and knackud
Code: Select all
pi@raspberrypi ~ $ python /home/pi/domoticz/scripts/Denon_Airplay_Check.py
Socket successfully created
Host = 192.168.1.12 Port = 23
Connecting to Denon Amplifier-
simon_rb
- Posts: 612
- Joined: Wednesday 07 August 2013 19:09
- Target OS: -
- Domoticz version:
- Location: UK
- Contact:
Re: Telnet Type Data to Domoticz Help
Got the script to run but it stops after it displays Connecting to Denon... After a couple of mins I hit ctrl c and this is what it displays.. We are too close... Well you are 
Code: Select all
pi@raspberrypi ~ $ python /home/pi/domoticz/scripts/Denon_Airplay_Check.py
Socket successfully created
Host = 192.168.1.12 Port = 23
Connecting to Denon Amplifier
^CTraceback (most recent call last):
File "/home/pi/domoticz/scripts/Denon_Airplay_Check.py", line 49, in <module>
ReceiveData()
File "/home/pi/domoticz/scripts/Denon_Airplay_Check.py", line 28, in ReceiveData
DStart = (s.recv(3)) # Get next 3 characters
KeyboardInterrupt
pi@raspberrypi ~ $ Who is online
Users browsing this forum: No registered users and 1 guest