Yamaha AV Receiver Plugin

Python and python framework
ohnsorge
Posts: 2
Joined: Tuesday 08 December 2015 1:10
Target OS: -
Domoticz version:
Contact:

Re: Yamaha AV Receiver Plugin

Post by ohnsorge » Friday 18 August 2017 17:57

Hi, when i install a plugin after few hours Domoticz show error:
2017-08-18 17:20:56.782 Domoticz V3.8153 (c)2012-2017 GizMoCuz
2017-08-18 17:20:56.783 Build Hash: 494fff7, Date: 2017-07-30 12:19:41
2017-08-18 17:20:56.783 Startup Path: /home/pi/domoticz/
2017-08-18 17:20:56.830 Sunrise: 05:42:00 SunSet:20:10:00
2017-08-18 17:20:56.830 EventSystem: reset all events...
2017-08-18 17:20:56.993 PluginSystem: Started, Python version '3.4.2'.
2017-08-18 17:20:56.994 Using 1-Wire support (OWFS)...
2017-08-18 17:20:57.009 Active notification Subsystems: (0/12)
2017-08-18 17:20:57.018 WebServer(HTTP) started on address: 0.0.0.0 with port 8080
2017-08-18 17:20:57.042 Error: WebServer(SSL) startup failed on address 0.0.0.0 with port: 443: bind: Permission denied
2017-08-18 17:20:57.042 Error: WebServer(SSL) check privileges for opening ports below 1024
2017-08-18 17:20:57.043 Proxymanager started.
2017-08-18 17:20:57.046 Starting shared server on: 0.0.0.0:6144
2017-08-18 17:20:57.046 TCPServer: shared server started...
2017-08-18 17:20:57.047 RxQueue: queue worker started...
2017-08-18 17:20:59.059 Wunderground: Worker started...
2017-08-18 17:20:59.060 EventSystem: reset all events...
2017-08-18 17:20:59.062 EventSystem: reset all device statuses...
2017-08-18 17:20:59.334 PluginSystem: Entering work loop.
2017-08-18 17:20:59.551 (Yamaha RXV) Initialized version 1.0.0, author 'thomasvillagers'
Naruszenie ochrony pamięci

Have you meet something like this?
Sorry for my english :)

EJanus
Posts: 3
Joined: Thursday 24 August 2017 17:15
Target OS: Raspberry Pi
Domoticz version: 3.8153
Location: Netherlands
Contact:

Re: Yamaha AV Receiver Plugin

Post by EJanus » Thursday 24 August 2017 20:02

I've been trying for hours to get this to work, but no success. I hope you can take some time to help me out.

The plugin made by thomasvillagers works really well! But now I want to use zone2 as well. So I took the code that jimtrout87 wrote and tried to put it in the latest update of thomasvillagers plugin.py (because the code that jimtrout87 posted earlier, doesn't work anymore).

What I've been trying to do is this:

Code: Select all

 # Basic Python Plugin 
#
# Author: thomas-villagers
#
"""
<plugin key="YamahaPlug" name="Yamaha AV Receiver" author="thomasvillagers" version="1.0.0" wikilink="http://www.domoticz.com/wiki/plugins/plugin.html" externallink="https://yamaha.com/products/audio_visual/av_receivers_amps/">
    <params>
     <param field="Address" label="IP Address" width="200px" required="true" default="192.168.1.10"/>
     <param field="Port" label="Port" width="50px" required="true" default="50000"/>
     <param field="Mode6" label="Debug" width="75px">
       <options>
          <option label="True" value="Debug"/>
          <option label="False" value="Normal"  default="true" />
       </options>
     </param>
    </params>
</plugin>
"""
import Domoticz
import base64

class BasePlugin:
    enabled = False
    isConnected = True
    outstandingPings = 0
    nextConnect = 0
    commandArray = ["@MAIN:VOL=?", "@MAIN:INP=?", "@MAIN:MUTE=?", "@MAIN:SOUNDPRG=?", "@MAIN:SCENE=?", "@MAIN:PWR=?","@ZONE2:VOL=?", "@ZONE2:INP=?", "@MAIN:ZONE2=?", "@ZONE2:SOUNDPRG=?", "@ZONE2:SCENE=?", "@ZONE2:PWR=?"]
    commandIndex = 0 

    def __init__(self):
        #self.var = 123
        return

    def onStart(self):
        if Parameters["Mode6"] == "Debug":
           Domoticz.Debugging(1)
        Domoticz.Debug("onStart called")
        if (len(Devices) == 0):
            Domoticz.Device(Name="Status",  Unit=1, Type=17,  Switchtype=17).Create()          
            Domoticz.Device(Name="Volume",  Unit=2, Type=244, Subtype=73, Switchtype=7,  Image=8).Create()
            LevelActions= "LevelActions:"+stringToBase64("||||")+";"
            LevelNames= "LevelNames:"+stringToBase64("Off|Scene1|Scene2|Scene3|Scene4|Other")+";"
            Other= "LevelOffHidden:ZmFsc2U=;SelectorStyle:MA==" # true is "dHJ1ZQ==", 1 is "MQ=="
            Options=LevelActions+LevelNames+Other
            Domoticz.Device(Name="Source", Unit=3, TypeName="Selector Switch", Options=Options).Create()
            Domoticz.Device(Name="Zone 2 Status",  Unit=4, Type=17,  Switchtype=17).Create()          
            Domoticz.Device(Name="Zone 2 Volume",  Unit=5, Type=244, Subtype=73, Switchtype=7,  Image=8).Create()
            LevelActions= "LevelActions:"+stringToBase64("|||")+";"
            LevelNames= "LevelNames:"+stringToBase64("Off|Main Sync|Input1|Other")+";"
            Other= "LevelOffHidden:ZmFsc2U=;SelectorStyle:MA==" # true is "dHJ1ZQ==", 1 is "MQ=="
            Options=LevelActions+LevelNames+Other
            Domoticz.Device(Name="Zone 2 Source", Unit=6, TypeName="Selector Switch", Options=Options).Create()

        self.connection = Domoticz.Connection(Name="Yamaha connection", Transport="TCP/IP", Protocol="Line", Address=Parameters["Address"], Port=Parameters["Port"])
        self.connection.Connect()
        Domoticz.Heartbeat(20)

    def onStop(self):
        Domoticz.Log("onStop called")

    def onConnect(self, Connection, Status, Description):
        Domoticz.Debug("onConnect called. Status: " + str(Status))
        if (Status == 0): 
          self.isConnected = True
#         UpdateDevice(1,1,"")
          self.onHeartbeat()
        else: 
          self.isConnected = False

    def onMessage(self, Connection, Data, Status, Extra):
        Domoticz.Debug("onMessage called")
        self.outstandingPings = self.outstandingPings - 1
        strData = Data.decode("utf-8", "ignore")
        arrData = strData.split('=')
        for x in arrData:
            Domoticz.Debug(x)
        if (arrData[0] == "@MAIN:VOL"):
            vol = float(arrData[1])
            sliderValue = int(vol*5/4 + 100)
			if (Devices[1].sValue == "On"):
                UpdateDevice(2,2,str(sliderValue)) 
        elif (arrData[0] == "@MAIN:INP"): 
            s = arrData[1]
            if (Devices[1].sValue == "On"):
                if (s == "HDMI1"):
                    UpdateDevice(3,2,str(10))
                elif (s == "HDMI2"):
                    UpdateDevice(3,2,str(20))
                elif (s == "AUDIO1"):
                    UpdateDevice(3,2,str(30))
                elif (s == "TUNER"):
                    UpdateDevice(3,2,str(40))
                else: 
                    UpdateDevice(3,2,str(50))
        elif (arrData[0] == "@MAIN:PWR"):
            p = arrData[1]
            Domoticz.Log(p)
            if (p == "On"):
                UpdateDevice(1,1,"On")            
            elif (p == "Standby"):
                UpdateDevice(1,0,"Standby")
                UpdateDevice(2,0,Devices[2].sValue)
                UpdateDevice(3,0,Devices[3].sValue)
        elif (arrData[0] == "@ZONE2:VOL"):
            vol = float(arrData[1])
            sliderValue = int(vol*5/4 + 100)
            if (Devices[4].sValue == "On"):
                UpdateDevice(5,2,str(sliderValue)) 
        elif (arrData[0] == "@ZONE2:INP"): 
            s = arrData[1]
            if (Devices[4].sValue == "On"):
                if (s == "Main Zone Sync"):
                    UpdateDevice(6,2,str(10))
                elif (s == "AUDIO1"):
                    UpdateDevice(6,2,str(20))
                else: 
                    UpdateDevice(6,2,str(30))
        elif (arrData[0] == "@ZONE2:PWR"):
            p = arrData[1]
            Domoticz.Log(p)
            if (p == "On"):
                UpdateDevice(4,1,"On")                
            elif (p == "Standby"):
                UpdateDevice(4,0,"Standby")
                UpdateDevice(5,0,Devices[5].sValue)
                UpdateDevice(6,0,Devices[6].sValue)

    def onCommand(self, Unit, Command, Level, Hue):
        Domoticz.Debug("onCommand called for Unit " + str(Unit) + ": Parameter '" + str(Command) + "', Level: " + str(Level))
        if (self.isConnected == False):
            self.connection.Connect() 
            return
        if (Unit == 1):
            if (Command == "Off"):
                UpdateDevice(1,0,Devices[1].sValue) # TODO remove
                self.connection.Send("@MAIN:PWR=Standby\r\n")
            elif (Command == "On"): 
               self.connection.Send("@MAIN:PWR=On\r\n")
        elif (Unit == 2): 
            if (Command == "Set Level"): 
                volume = int(Level)*4/5 - 80
                volumeToSend = round(2*volume)/2
                self.connection.Send("@MAIN:VOL="+str(volumeToSend)+"\r\n") 
        elif (Unit == 3): 
            input = str(int(int(Level)/10))
            self.connection.Send("@MAIN:SCENE=Scene " + input + "\r\n")
        elif (Unit == 4):
            if (Command == "Off"):
                UpdateDevice(4,0,Devices[1].sValue) # TODO remove
                self.connection.Send("@ZONE2:PWR=Standby\r\n")
            elif (Command == "On"): 
                self.connection.Send("@ZONE2:PWR=On\r\n")
        elif (Unit == 5): 
            if (Command == "Set Level"): 
                volume = int(Level)*4/5 - 80
                volumeToSend = round(2*volume)/2
                self.connection.Send("@ZONE2:VOL="+str(volumeToSend)+"\r\n")
        elif (Unit == 6): 
            input = str(int(int(Level)/10))
            if (input == "1"):
                self.connection.Send("@ZONE2:INP=Main Zone Sync" + "\r\n")
            elif (input == "2"):
                self.connection.Send("@ZONE2:INP=AUDIO1" + "\r\n")

    def onNotification(self, Data):
        Domoticz.Debug("onNotification: " + str(Data))

    def onDisconnect(self, Connection):
        Domoticz.Debug("onDisconnect called")
        self.isConnected = False 
 #       UpdateDevice(1,0,"")
 #       UpdateDevice(2,0,Devices[2].sValue)
 #       UpdateDevice(3,0,Devices[3].sValue)

    def onHeartbeat(self):
        Domoticz.Debug("onHeartbeat called. Connected: " + str(self.isConnected))
        if (self.isConnected == True):
            if (self.outstandingPings > 6):
                Domoticz.Debug("Missed more than 6 pings - disconnect")
                self.connection.Disconnect()  # obsolete 
                self.nextConnect = 0
            else:   
                self.connection.Send(self.commandArray[self.commandIndex] + "\r\n")
                self.commandIndex = (self.commandIndex + 1 ) % len(self.commandArray)
                self.outstandingPings = self.outstandingPings + 1
        else: 
            self.outstandingPings = 0
            self.nextConnect = self.nextConnect - 1
            if (self.nextConnect <= 0):
                self.nextConnect = 3
                self.connection.Connect()  # obsolete 

global _plugin
_plugin = BasePlugin()

def onStart():
    global _plugin
    _plugin.onStart()

def onStop():
    global _plugin
    _plugin.onStop()

def onConnect(Connection, Status, Description):
    global _plugin
    _plugin.onConnect(Connection, Status, Description)

def onMessage(Connection, Data, Status, Extra):
    global _plugin
    _plugin.onMessage(Connection, Data, Status, Extra)

def onCommand(Unit, Command, Level, Hue):
    global _plugin
    _plugin.onCommand(Unit, Command, Level, Hue)

def onNotification(Data):
    global _plugin
    _plugin.onNotification(Data)

def onDisconnect(Connection):
    global _plugin
    _plugin.onDisconnect(Connection)

def onHeartbeat():
    global _plugin
    _plugin.onHeartbeat()

def UpdateDevice(Unit, nValue, sValue):
    # Make sure that the Domoticz device still exists (they can be deleted) before updating it 
    if (Unit in Devices):
        if (Devices[Unit].nValue != nValue) or (Devices[Unit].sValue != sValue):
            Devices[Unit].Update(nValue, str(sValue))
            Domoticz.Log("Update "+str(nValue)+":'"+str(sValue)+"' ("+Devices[Unit].Name+")")
    return

    # Generic helper functions
def DumpConfigToLog():
    for x in Parameters:
        if Parameters[x] != "":
            Domoticz.Debug( "'" + x + "':'" + str(Parameters[x]) + "'")
    Domoticz.Debug("Device count: " + str(len(Devices)))
    for x in Devices:
        Domoticz.Debug("Device:           " + str(x) + " - " + str(Devices[x]))
        Domoticz.Debug("Device ID:       '" + str(Devices[x].ID) + "'")
        Domoticz.Debug("Device Name:     '" + Devices[x].Name + "'")
        Domoticz.Debug("Device nValue:    " + str(Devices[x].nValue))
        Domoticz.Debug("Device sValue:   '" + Devices[x].sValue + "'")
        Domoticz.Debug("Device LastLevel: " + str(Devices[x].LastLevel))
    return

def stringToBase64(s):
    return base64.b64encode(s.encode('utf-8')).decode("utf-8")

def base64ToString(b):
    return base64.b64decode(b).decode('utf-8')
 

It doesn't work. When I add hardware in Domoticz it seems to work after selecting this plugin, but when i go to the Devices nothing shows up. Domoticz log tells me that there is an error in line 80, but I don't understand how I should fix this.

Line 80: if (Devices[1].sValue == "On"):

Please help me out.

EJanus
Posts: 3
Joined: Thursday 24 August 2017 17:15
Target OS: Raspberry Pi
Domoticz version: 3.8153
Location: Netherlands
Contact:

Re: Yamaha AV Receiver Plugin

Post by EJanus » Friday 01 September 2017 16:56

jimtrout87 wrote:
Monday 06 March 2017 11:36
Ok so i tried this myself and managed to get the scenes working if anyone is interested...
Hi Jim,

As you can read in my last post, your code doesn't work anymore. I tried to fix it by combining your code with the newest plugin of thomas, but I failed (becourse I have no programming skills). Can you help me out? I really would like to be able to use zone2 etc. like you posted before.

EJanus
Posts: 3
Joined: Thursday 24 August 2017 17:15
Target OS: Raspberry Pi
Domoticz version: 3.8153
Location: Netherlands
Contact:

Re: Yamaha AV Receiver Plugin

Post by EJanus » Wednesday 06 September 2017 17:28

I Think I solved it. Right now I'm testing if and how everything works. Will report back later.

Remicade
Posts: 12
Joined: Friday 15 September 2017 21:43
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Yamaha AV Receiver Plugin

Post by Remicade » Friday 15 September 2017 22:00

Hi, on my rx-v677 it is sort of running. I o not use any additional scripts, only the plugin.
Volume works. Selector works. But when I power off the amp Domoticz still says the it is on.
How to get the Yamaha logos is my other question.
Thanks Paul

Remicade
Posts: 12
Joined: Friday 15 September 2017 21:43
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Yamaha AV Receiver Plugin

Post by Remicade » Friday 15 September 2017 22:00

Hi, on my rx-v677 it is sort of running. I do not use any additional scripts, only the plugin.
Volume works. Selector works. But when I power off the amp Domoticz still says that it is on.
How to get the Yamaha logos is my other question.
Thanks Paul
Last edited by Remicade on Saturday 16 September 2017 10:30, edited 1 time in total.

Goldwing1973
Posts: 111
Joined: Monday 08 August 2016 22:55
Target OS: Linux
Domoticz version: Stable
Location: Netherlands, Alphen aan den Rijn
Contact:

Re: Yamaha AV Receiver Plugin

Post by Goldwing1973 » Friday 15 September 2017 23:26

2017-09-15 23:23:26.617 Error: (Yamaha Reciever Woonkamer) 'onMessage' failed 'TypeError':'onMessage() missing 2 required positional arguments: 'Status' and 'Extra''.

Thats what i'm getting with my Yamaha RX-V477, it would be nice to get it working.
Over 50 Z-Wave Devices (Fibaro and Neo), 4xLogitech Hub, 2xPhilips Hue Bridge+55 Lights, 1x Nest Thermostat, 2xNetatmo Weather Station, 1xSkybell v1 Doorbell, 3 Kwikset KEVO Doorlocks and Domoticz running on a Intel NUC

Remicade
Posts: 12
Joined: Friday 15 September 2017 21:43
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Yamaha AV Receiver Plugin

Post by Remicade » Saturday 16 September 2017 14:15

Hi,
After a restart, (Domoticz hangs some times, I have to copy the auto restart and monitoring script) in my log I find this...

2017-09-16 14:12:51.793 Error: (Yamaha) 'onMessage' failed 'ValueError':'invalid literal for int() with base 10: 'y''.
2017-09-16 14:12:51.793 Error: (Yamaha) ----> Line 159 in /home/pi/domoticz/plugins/Yamaha/plugin.py, function onMessage
2017-09-16 14:12:51.793 Error: (Yamaha) ----> Line 85 in /home/pi/domoticz/plugins/Yamaha/plugin.py, function onMessage

What could this be?
Thanks Paul

Remicade
Posts: 12
Joined: Friday 15 September 2017 21:43
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Yamaha AV Receiver Plugin

Post by Remicade » Sunday 17 September 2017 17:30

Could this be an answer to my earlier question:
The error is "invalid literal for int() with base 10:". This just means that the argument that you passed to int doesn't look like a number. In other words it's either empty, or has a character in it other than a digit.

This can be reproduced in a python shell.

>>> int("x")
ValueError: invalid literal for int() with base 10: 'x'

But change int into what?
Thanks Paul

Damnet
Posts: 14
Joined: Friday 24 February 2017 21:43
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Yamaha AV Receiver Plugin

Post by Damnet » Friday 29 September 2017 22:27

Goldwing1973 wrote:
Friday 15 September 2017 23:26
2017-09-15 23:23:26.617 Error: (Yamaha Reciever Woonkamer) 'onMessage' failed 'TypeError':'onMessage() missing 2 required positional arguments: 'Status' and 'Extra''.

Thats what i'm getting with my Yamaha RX-V477, it would be nice to get it working.
Agree im getting the same errors fyi. 'onMessage' failed 'TypeError':'onMessage() missing 2 required positional arguments: 'Status' and 'Extra''.

HTR4065 receiver with Domoticz Version: 3.8209 on RPi.

thomasvillagers
Posts: 19
Joined: Monday 06 February 2017 16:57
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Yamaha AV Receiver Plugin

Post by thomasvillagers » Saturday 07 October 2017 15:01

Hi!
Agree im getting the same errors fyi. 'onMessage' failed 'TypeError':'onMessage() missing 2 required positional arguments: 'Status' and 'Extra''.
fixed.
The error is "invalid literal for int() with base 10:". This just means that the argument that you passed to int doesn't look like a number. In other words it's either empty, or has a character in it other than a digit.
hm, cannot confirm this one ...

In addition, I refactored a few things and added a new device for controlling your AV inputs.

You can rename the input names in the two selector switches and you can delete unused ones. But you MUST keep them in order. That means, you can delete the unused inputs HDMI7, HDMI6 etc. but you CAN'T delete i. e. HDMI1 and keep the others.

You can find the updated version on Github. Hope "most" of the bugs are fixed (there are still plenty, sorry ...).

Icon images attached!

- thomas
Attachments
yamaha.zip
(8.83 KiB) Downloaded 77 times

zicht
Posts: 202
Joined: Sunday 11 May 2014 11:09
Target OS: Windows
Domoticz version: 3.8xxx
Location: NL
Contact:

Re: Yamaha AV Receiver Plugin

Post by zicht » Friday 03 November 2017 0:09

Hi Thomas !
Thanks man, works like a charm.

Adjusted the code a bit for all input on my v773 (HDMI1-5 AV1-6 AUDIO1-2, NET, USB, V-AUX)

Code: Select all

# Basic Python Plugin 
#
# Author: thomas-villagers
#
"""
<plugin key="YamahaPlug" name="Yamaha AV Receiver" author="thomasvillagers" version="1.0.0" wikilink="http://www.domoticz.com/wiki/plugins/plugin.html" externallink="https://yamaha.com/products/audio_visual/av_receivers_amps/">
    <params>
     <param field="Address" label="IP Address" width="200px" required="true" default="127.0.0.1"/>
     <param field="Port" label="Port" width="50px" required="true" default="50000"/>
     <param field="Mode6" label="Debug" width="75px">
       <options>
          <option label="True" value="Debug"/>
          <option label="False" value="Normal"  default="true" />
       </options>
     </param>
    </params>
</plugin>
"""
import Domoticz
import base64

class BasePlugin:
    enabled = False
    isConnected = True
    outstandingPings = 0
    nextConnect = 0
    commandArray = ["@MAIN:VOL=?", "@MAIN:INP=?", "@MAIN:MUTE=?", "@MAIN:SOUNDPRG=?"]
    commandIndex = 0 

    def __init__(self):
        #self.var = 123
        return

    def onStart(self):
        if Parameters["Mode6"] == "Debug":
           Domoticz.Debugging(1)
        Domoticz.Debug("onStart called")
        if 1 not in Devices: 
            Domoticz.Debug("Create Status Device")
            Domoticz.Device(Name="Status",  Unit=1, Type=17,  Switchtype=17, Used=1).Create()          
        if 2 not in Devices: 
            Domoticz.Debug("Create Volume Device")
            Domoticz.Device(Name="Volume",  Unit=2, Type=244, Subtype=73, Switchtype=7,  Image=8, Used=1).Create()
        if 3 not in Devices: 
            Domoticz.Debug("Create HDMI Device")
            Options = { "LevelActions" : "|||||||",
                        "LevelNames"   : "Off|HDMI1|HDMI2|HDMI3|HDMI4|HDMI5",
                        "LevelOffHidden" : "true",
                        "SelectorStyle" : "0" 
                      }
            Domoticz.Device(Name="Source", Unit=3, TypeName="Selector Switch", Switchtype=18, Options=Options, Used=1).Create()
        if 4 not in Devices:
            Domoticz.Debug("Create AV Device")
            Options = { "LevelActions" : "||||||",
                        "LevelNames"   : "Off|AV1|AV2|AV3|AV4|AV5|AV6",
                        "LevelOffHidden" : "true",
                        "SelectorStyle" : "0"
                      }
            Domoticz.Device(Name="AV Source", Unit=4, TypeName="Selector Switch", Switchtype=18, Options=Options, Used=1).Create() 
        if 5 not in Devices:
            Domoticz.Debug("Create AUDIO Device")
            Options = { "LevelActions" : "||||||",
                        "LevelNames"   : "Off|AUDIO 1|AUDIO 2|NET|USB|V-AUX",
                        "LevelOffHidden" : "true",
                        "SelectorStyle" : "0"
                      }
            Domoticz.Device(Name="AUDIO Source", Unit=5, TypeName="Selector Switch", Switchtype=18, Options=Options, Used=1).Create() 


        self.connection = Domoticz.Connection(Name="Yamaha connection", Transport="TCP/IP", Protocol="Line", Address=Parameters["Address"], Port=Parameters["Port"])
        self.connection.Connect()
        Domoticz.Heartbeat(20)

    def onStop(self):
        Domoticz.Log("onStop called")

    def onConnect(self, Connection, Status, Description):
        Domoticz.Debug("onConnect called. Status: " + str(Status))
        if (Status == 0): 
          self.isConnected = True
          UpdateDevice(1,1,"")
          self.onHeartbeat()
        else: 
          self.isConnected = False

    def onMessage(self, Connection, Data):
        Domoticz.Debug("onMessage called")
        self.outstandingPings = self.outstandingPings - 1
        strData = Data.decode("utf-8", "ignore")
        arrData = strData.split('=')
        for x in arrData:
            Domoticz.Debug(x)
        if (arrData[0] == "@MAIN:VOL"):
            vol = float(arrData[1])
            sliderValue = int(vol*5/4 + 100)
            UpdateDevice(2, Devices[2].nValue, str(sliderValue))
        elif (arrData[0] == "@MAIN:MUTE"): 
            if (arrData[1] == "Off"):
                UpdateDevice(2, 2, Devices[2].sValue)
            elif (arrData[1] == "On"): 
                UpdateDevice(2, 0, Devices[2].sValue)
        elif (arrData[0] == "@MAIN:INP"): 
            s = arrData[1]
            if (s.startswith("HDMI")) or (s.startswith("AV")) or  (s.startswith("AUDIO")) :
              inp = int(s[-1:])
            if (s.startswith("HDMI")):
              UpdateDevice(3,2,str(inp*10))
              UpdateDevice(4,2,"0")
              UpdateDevice(5,2,"0")
            elif (s.startswith("AV")):
              UpdateDevice(4,2,str(inp*10))  
              UpdateDevice(5,2,"0")
              UpdateDevice(3,2,"0")
            elif (s.startswith("AUDIO")):
              UpdateDevice(5,2,str(inp*10))  
              UpdateDevice(4,2,"0")  
              UpdateDevice(3,2,"0")
            elif (s.startswith("NET")):
              UpdateDevice(5,2,str(30))  
              UpdateDevice(4,2,"0")  
              UpdateDevice(3,2,"0")
            elif (s.startswith("USB")):
              UpdateDevice(5,2,str(40))  
              UpdateDevice(4,2,"0")  
              UpdateDevice(3,2,"0")
            elif (s.startswith("V-AUX")):
              UpdateDevice(5,2,str(50))  
              UpdateDevice(4,2,"0")  
              UpdateDevice(3,2,"0")
        elif (arrData[0] == "@MAIN:SOUNDPRG"):
            UpdateDevice(1,1, arrData[1])


    def onCommand(self, Unit, Command, Level, Hue):
        Domoticz.Debug("onCommand called for Unit " + str(Unit) + ": Parameter '" + str(Command) + "', Level: " + str(Level))
        if (self.isConnected == False):
            self.connection.Connect() 
            return
        if (Unit == 1):
            if (Command == "Off"):
                UpdateDevice(1,0,Devices[1].sValue) # TODO remove
                self.connection.Send("@MAIN:PWR=Standby\r\n")
            elif (Command == "On"): 
               self.connection.Send("@MAIN:PWR=On\r\n")
        elif (Unit == 2): 
            if (Command == "Set Level"): 
                volume = int(Level)*4/5 - 80
                volumeToSend = round(2*volume)/2
                self.connection.Send("@MAIN:VOL="+str(volumeToSend)+"\r\n") 
            elif (Command == "Off"): 
                self.connection.Send("@MAIN:MUTE=On\r\n") 
            elif (Command == "On"): 
                self.connection.Send("@MAIN:MUTE=Off\r\n") 
        elif (Unit == 3): 
            input = str(int(int(Level)/10))
            self.connection.Send("@MAIN:INP=HDMI" + input + "\r\n") 
        elif (Unit == 4):
            input = str(int(int(Level)/10))
            self.connection.Send("@MAIN:INP=AV" + input + "\r\n")
        elif (Unit == 5):
            input = str(int(int(Level)/10))
            if (input == "1" or input == "2"):
             self.connection.Send("@MAIN:INP=AUDIO" + input + "\r\n")
            elif (input == "3"):
             self.connection.Send("@MAIN:INP=NET RADIO" + "\r\n")
            elif (input == "4"):
             self.connection.Send("@MAIN:INP=USB" + "\r\n")
            elif (input == "5"):
             self.connection.Send("@MAIN:INP=V-AUX" + "\r\n")
			
    def onNotification(self, Data):
        Domoticz.Debug("onNotification: " + str(Data))

    def onDisconnect(self, Connection):
        Domoticz.Debug("onDisconnect called")
        self.isConnected = False 
        UpdateDevice(1,0,"")
        UpdateDevice(2,0,Devices[2].sValue)
        UpdateDevice(3,0,Devices[3].sValue)
        UpdateDevice(4,0,Devices[4].sValue)
        UpdateDevice(5,0,Devices[5].sValue)

    def onHeartbeat(self):
        Domoticz.Debug("onHeartbeat called. Connected: " + str(self.isConnected))
        if (self.isConnected == True):
            if (self.outstandingPings > 6):
                Domoticz.Debug("Missed more than 6 pings - disconnect")
                self.connection.Disconnect()  # obsolete 
                self.nextConnect = 0
            else:   
                self.connection.Send(self.commandArray[self.commandIndex] + "\r\n")
                self.commandIndex = (self.commandIndex + 1 ) % len(self.commandArray)
                self.outstandingPings = self.outstandingPings + 1
        else: 
            self.outstandingPings = 0
            self.nextConnect = self.nextConnect - 1
            if (self.nextConnect <= 0):
                self.nextConnect = 3
                self.connection.Connect()  # obsolete 

global _plugin
_plugin = BasePlugin()

def onStart():
    global _plugin
    _plugin.onStart()

def onStop():
    global _plugin
    _plugin.onStop()

def onConnect(Connection, Status, Description):
    global _plugin
    _plugin.onConnect(Connection, Status, Description)

def onMessage(Connection, Data):
    global _plugin
    _plugin.onMessage(Connection, Data)

def onCommand(Unit, Command, Level, Hue):
    global _plugin
    _plugin.onCommand(Unit, Command, Level, Hue)

def onNotification(Data):
    global _plugin
    _plugin.onNotification(Data)

def onDisconnect(Connection):
    global _plugin
    _plugin.onDisconnect(Connection)

def onHeartbeat():
    global _plugin
    _plugin.onHeartbeat()

def UpdateDevice(Unit, nValue, sValue):
    # Make sure that the Domoticz device still exists (they can be deleted) before updating it 
    if (Unit in Devices):
        if (Devices[Unit].nValue != nValue) or (Devices[Unit].sValue != sValue):
            Devices[Unit].Update(nValue, str(sValue))
            Domoticz.Log("Update "+str(nValue)+":'"+str(sValue)+"' ("+Devices[Unit].Name+")")
    return

    # Generic helper functions
def DumpConfigToLog():
    for x in Parameters:
        if Parameters[x] != "":
            Domoticz.Debug( "'" + x + "':'" + str(Parameters[x]) + "'")
    Domoticz.Debug("Device count: " + str(len(Devices)))
    for x in Devices:
        Domoticz.Debug("Device:           " + str(x) + " - " + str(Devices[x]))
        Domoticz.Debug("Device ID:       '" + str(Devices[x].ID) + "'")
        Domoticz.Debug("Device Name:     '" + Devices[x].Name + "'")
        Domoticz.Debug("Device nValue:    " + str(Devices[x].nValue))
        Domoticz.Debug("Device sValue:   '" + Devices[x].sValue + "'")
        Domoticz.Debug("Device LastLevel: " + str(Devices[x].LastLevel))
    return

def stringToBase64(s):
    return base64.b64encode(s.encode('utf-8')).decode("utf-8")

def base64ToString(b):
    return base64.b64decode(b).decode('utf-8')
As i am not a coder at all I am sure my code is not the most beautifull thing, but it works for me at the moment.
Sorry if i used some dirty code to get the functionality.

note : Now looking into zone 2 input selection and volume, but i am stuck on the selection of zone 2 :shock:
Rpi & Win x64. Using : cam's,Nest,RFXCom,Kaku,LaCrosse,RFY,IsAlive,Dummy,Wether Underground, standard Lua, Curl on windows,Domoticz Android App & Tasker,

"The only source of knowledge is experience (A.Einstein)"

zicht
Posts: 202
Joined: Sunday 11 May 2014 11:09
Target OS: Windows
Domoticz version: 3.8xxx
Location: NL
Contact:

Re: Yamaha AV Receiver Plugin

Post by zicht » Monday 06 November 2017 9:05

All credits to Thomas !

Adjusted the code a bit for all input on my v773
MAIN ON/OFF Volume&Mute (HDMI1-5 AV1-6 AUDIO1-2, NET, USB, V-AUX)
ZONE2 ON/OFF Volume&Mute (Audio1-2,Net,USB)

Code: Select all

# Basic Python Plugin 
#
# Author: thomas-villagers
#
"""
<plugin key="YamahaPlug" name="Yamaha AV Receiver" author="thomasvillagers" version="1.0.0" wikilink="http://www.domoticz.com/wiki/plugins/plugin.html" externallink="https://yamaha.com/products/audio_visual/av_receivers_amps/">
    <params>
     <param field="Address" label="IP Address" width="200px" required="true" default="127.0.0.1"/>
     <param field="Port" label="Port" width="50px" required="true" default="50000"/>
     <param field="Mode6" label="Debug" width="75px">
       <options>
          <option label="True" value="Debug"/>
          <option label="False" value="Normal"  default="true" />
       </options>
     </param>
    </params>
</plugin>
"""
import Domoticz
import base64

class BasePlugin:
    enabled = False
    isConnected = True
    outstandingPings = 0
    nextConnect = 0
    commandArray = ["@MAIN:SOUNDPRG=?", "@MAIN:PWR=?", "@MAIN:VOL=?", "@MAIN:INP=?", "@MAIN:MUTE=?", "@ZONE2:PWR=?", "@ZONE2:VOL=?", "@ZONE2:MUTE=?", "@ZONE2:INP=?"]
	#commandArray = ["@MAIN:VOL=?", "@MAIN:INP=?", "@MAIN:MUTE=?", "@MAIN:SOUNDPRG=?"]
    commandIndex = 0 

    def __init__(self):
        #self.var = 123
        return

    def onStart(self):
        if Parameters["Mode6"] == "Debug":
           Domoticz.Debugging(1)
        Domoticz.Debug("onStart called")
        if 1 not in Devices: 
            Domoticz.Debug("Create Status Device")
            Domoticz.Device(Name="Status",  Unit=1, Type=17,  Switchtype=17, Used=1).Create()          
        if 2 not in Devices: 
            Domoticz.Debug("Create Volume Device")
            Domoticz.Device(Name="Volume",  Unit=2, Type=244, Subtype=73, Switchtype=7,  Image=8, Used=1).Create()
        if 3 not in Devices: 
            Domoticz.Debug("Create HDMI Device")
            Options = { "LevelActions" : "|||||||",
                        "LevelNames"   : "Off|HDMI1|HDMI2|HDMI3|HDMI4|HDMI5",
                        "LevelOffHidden" : "true",
                        "SelectorStyle" : "0" 
                      }
            Domoticz.Device(Name="Source", Unit=3, TypeName="Selector Switch", Switchtype=18, Options=Options, Used=1).Create()
        if 4 not in Devices:
            Domoticz.Debug("Create AV Device")
            Options = { "LevelActions" : "||||||",
                        "LevelNames"   : "Off|AV1|AV2|AV3|AV4|AV5|AV6",
                        "LevelOffHidden" : "true",
                        "SelectorStyle" : "0"
                      }
            Domoticz.Device(Name="AV Source", Unit=4, TypeName="Selector Switch", Switchtype=18, Options=Options, Used=1).Create() 
        if 5 not in Devices:
            Domoticz.Debug("Create AUDIO Device")
            Options = { "LevelActions" : "||||||",
                        "LevelNames"   : "Off|AUDIO 1|AUDIO 2|NET|USB|V-AUX",
                        "LevelOffHidden" : "true",
                        "SelectorStyle" : "0"
                      }
            Domoticz.Device(Name="AUDIO Source", Unit=5, TypeName="Selector Switch", Switchtype=18, Options=Options, Used=1).Create() 
        if 6 not in Devices: 
            Domoticz.Debug("Create Status Z2 Device")
            Domoticz.Device(Name="Status Zone2",  Unit=6, Type=17,  Switchtype=17, Used=1).Create()          
        if 7 not in Devices: 
            Domoticz.Debug("Create Volume Zone 2 Device")
            Domoticz.Device(Name="Volume Zone2",  Unit=7, Type=244, Subtype=73, Switchtype=7,  Image=8, Used=1).Create()
        if 8 not in Devices:
            Domoticz.Debug("Create AUDIO Z2 Device")
            Options = { "LevelActions" : "||||||",
                        "LevelNames"   : "Off|AUDIO 1|AUDIO 2|NET|USB",
                        "LevelOffHidden" : "true",
                        "SelectorStyle" : "0"
                      }
            Domoticz.Device(Name="AUDIO Source Zone2", Unit=8, TypeName="Selector Switch", Switchtype=18, Options=Options, Used=1).Create() 


        self.connection = Domoticz.Connection(Name="Yamaha connection", Transport="TCP/IP", Protocol="Line", Address=Parameters["Address"], Port=Parameters["Port"])
        self.connection.Connect()
        Domoticz.Heartbeat(20)

    def onStop(self):
        Domoticz.Log("onStop called")

    def onConnect(self, Connection, Status, Description):
        Domoticz.Debug("onConnect called. Status: " + str(Status))
        if (Status == 0): 
          self.isConnected = True
          UpdateDevice(1,1,"")
          self.onHeartbeat()
        else: 
          self.isConnected = False

    def onMessage(self, Connection, Data):
        Domoticz.Debug("onMessage called")
        self.outstandingPings = self.outstandingPings - 1
        strData = Data.decode("utf-8", "ignore")
        arrData = strData.split('=')
        for x in arrData:
            Domoticz.Debug(x)
        if (arrData[0] == "@MAIN:VOL"):
            vol = float(arrData[1])
            sliderValue = int(vol*5/4 + 100)
            UpdateDevice(2, Devices[2].nValue, str(sliderValue))
        elif (arrData[0] == "@MAIN:MUTE"): 
            if (arrData[1] == "Off"):
                UpdateDevice(2, 2, Devices[2].sValue)
            elif (arrData[1] == "On"): 
                UpdateDevice(2, 0, Devices[2].sValue)
        elif (arrData[0] == "@MAIN:INP"): 
            s = arrData[1]
            if (s.startswith("HDMI")) or (s.startswith("AV")) or  (s.startswith("AUDIO")) :
              inp = int(s[-1:])
            if (s.startswith("HDMI")):
              UpdateDevice(3,2,str(inp*10))
              UpdateDevice(4,2,"0")
              UpdateDevice(5,2,"0")
            elif (s.startswith("AV")):
              UpdateDevice(4,2,str(inp*10))  
              UpdateDevice(5,2,"0")
              UpdateDevice(3,2,"0")
            elif (s.startswith("AUDIO")):
              UpdateDevice(5,2,str(inp*10))  
              UpdateDevice(4,2,"0")  
              UpdateDevice(3,2,"0")
            elif (s.startswith("NET")):
              UpdateDevice(5,2,str(30))  
              UpdateDevice(4,2,"0")  
              UpdateDevice(3,2,"0")
            elif (s.startswith("USB")):
              UpdateDevice(5,2,str(40))  
              UpdateDevice(4,2,"0")  
              UpdateDevice(3,2,"0")
            elif (s.startswith("V-AUX")):
              UpdateDevice(5,2,str(50))  
              UpdateDevice(4,2,"0")  
              UpdateDevice(3,2,"0")
        elif (arrData[0] == "@MAIN:SOUNDPRG"):
            UpdateDevice(1,1, arrData[1])
        elif (arrData[0] == "@MAIN:PWR"): 
            if (arrData[1] != "On"):
                UpdateDevice(1, 2, "Off") 
            #elif (arrData[1] == "Standby"): 
                #UpdateDevice(6, 2, "Off")
            #elif (arrData[1] == "On"): 
                #UpdateDevice(1, 2, "On")

        if (arrData[0] == "@ZONE2:VOL"):
            vol = float(arrData[1])
            sliderValue = int(vol*5/4 + 100)
            UpdateDevice(7, Devices[7].nValue, str(sliderValue))
        elif (arrData[0] == "@ZONE2:MUTE"): 
            if (arrData[1] == "Off"):
                UpdateDevice(7, 2, Devices[7].sValue)
            elif (arrData[1] == "On"): 
                UpdateDevice(7, 0, Devices[7].sValue)
        elif (arrData[0] == "@ZONE2:INP"): 
            s = arrData[1]
            if (s.startswith("HDMI")) or (s.startswith("AV")) or  (s.startswith("AUDIO")) :
              inp = int(s[-1:])
            elif (s.startswith("AUDIO")):
              UpdateDevice(8,2,str(inp*10))  
            elif (s.startswith("NET")):
              UpdateDevice(8,2,str(30))  
            elif (s.startswith("USB")):
              UpdateDevice(8,2,str(40))  
        elif (arrData[0] == "@ZONE2:PWR"): 
            if (arrData[1] != "On"):
                UpdateDevice(6, 0, "Off") 
            #elif (arrData[1] == "Standby"): 
                #UpdateDevice(6, 2, "Off")
            elif (arrData[1] == "On"): 
                UpdateDevice(6, 2, "On")

    def onCommand(self, Unit, Command, Level, Hue):
        Domoticz.Debug("onCommand called for Unit " + str(Unit) + ": Parameter '" + str(Command) + "', Level: " + str(Level))
        if (self.isConnected == False):
            self.connection.Connect() 
            return
        if (Unit == 1):
            if (Command == "Off"):
                UpdateDevice(1,0,Devices[1].sValue) # TODO remove
                self.connection.Send("@MAIN:PWR=Standby\r\n")
            elif (Command == "On"): 
               self.connection.Send("@MAIN:PWR=On\r\n")
        elif (Unit == 2): 
            if (Command == "Set Level"): 
                volume = int(Level)*4/5 - 80
                volumeToSend = round(2*volume)/2
                self.connection.Send("@MAIN:VOL="+str(volumeToSend)+"\r\n") 
            elif (Command == "Off"): 
                self.connection.Send("@MAIN:MUTE=On\r\n") 
            elif (Command == "On"): 
                self.connection.Send("@MAIN:MUTE=Off\r\n") 
        elif (Unit == 3): 
            input = str(int(int(Level)/10))
            self.connection.Send("@MAIN:INP=HDMI" + input + "\r\n") 
        elif (Unit == 4):
            input = str(int(int(Level)/10))
            self.connection.Send("@MAIN:INP=AV" + input + "\r\n")
        elif (Unit == 5):
            input = str(int(int(Level)/10))
            if (input == "1" or input == "2"):
             self.connection.Send("@MAIN:INP=AUDIO" + input + "\r\n")
            elif (input == "3"):
             self.connection.Send("@MAIN:INP=NET RADIO" + "\r\n")
            elif (input == "4"):
             self.connection.Send("@MAIN:INP=USB" + "\r\n")
            elif (input == "5"):
             self.connection.Send("@MAIN:INP=V-AUX" + "\r\n")

        if (Unit == 6):
            if (Command == "Off"):
                UpdateDevice(6,0,Devices[6].sValue) # TODO remove
                self.connection.Send("@ZONE2:PWR=Standby\r\n")
            elif (Command == "On"): 
               self.connection.Send("@ZONE2:PWR=On\r\n")
        elif (Unit == 7): 
            if (Command == "Set Level"): 
                volume = int(Level)*4/5 - 80
                volumeToSend = round(2*volume)/2
                self.connection.Send("@ZONE2:VOL="+str(volumeToSend)+"\r\n") 
            elif (Command == "Off"): 
                self.connection.Send("@ZONE2:MUTE=On\r\n") 
            elif (Command == "On"): 
                self.connection.Send("@ZONE2:MUTE=Off\r\n") 
        elif (Unit == 8):
            input = str(int(int(Level)/10))
            if (input == "1" or input == "2"):
             self.connection.Send("@ZONE2:INP=AUDIO" + input + "\r\n")
            elif (input == "3"):
             self.connection.Send("@ZONE2:INP=NET RADIO" + "\r\n")
            elif (input == "4"):
             self.connection.Send("@ZONE2:INP=USB" + "\r\n")
            elif (input == "5"):
             self.connection.Send("@ZONE2:INP=V-AUX" + "\r\n")
			 
    def onNotification(self, Data):
        Domoticz.Debug("onNotification: " + str(Data))

    def onDisconnect(self, Connection):
        Domoticz.Debug("onDisconnect called")
        self.isConnected = False 
        UpdateDevice(1,0,"")
        UpdateDevice(2,0,Devices[2].sValue)
        UpdateDevice(3,0,Devices[3].sValue)
        UpdateDevice(4,0,Devices[4].sValue)
        UpdateDevice(5,0,Devices[5].sValue)
        UpdateDevice(6,0,Devices[6].sValue)
        UpdateDevice(7,0,Devices[7].sValue)
        UpdateDevice(8,0,Devices[8].sValue)

    def onHeartbeat(self):
        Domoticz.Debug("onHeartbeat called. Connected: " + str(self.isConnected))
        if (self.isConnected == True):
            if (self.outstandingPings > 6):
                Domoticz.Debug("Missed more than 6 pings - disconnect")
                self.connection.Disconnect()  # obsolete 
                self.nextConnect = 0
            else:   
                self.connection.Send(self.commandArray[self.commandIndex] + "\r\n")
                self.commandIndex = (self.commandIndex + 1 ) % len(self.commandArray)
                self.outstandingPings = self.outstandingPings + 1
        else: 
            self.outstandingPings = 0
            self.nextConnect = self.nextConnect - 1
            if (self.nextConnect <= 0):
                self.nextConnect = 3
                self.connection.Connect()  # obsolete 

global _plugin
_plugin = BasePlugin()

def onStart():
    global _plugin
    _plugin.onStart()

def onStop():
    global _plugin
    _plugin.onStop()

def onConnect(Connection, Status, Description):
    global _plugin
    _plugin.onConnect(Connection, Status, Description)

def onMessage(Connection, Data):
    global _plugin
    _plugin.onMessage(Connection, Data)

def onCommand(Unit, Command, Level, Hue):
    global _plugin
    _plugin.onCommand(Unit, Command, Level, Hue)

def onNotification(Data):
    global _plugin
    _plugin.onNotification(Data)

def onDisconnect(Connection):
    global _plugin
    _plugin.onDisconnect(Connection)

def onHeartbeat():
    global _plugin
    _plugin.onHeartbeat()

def UpdateDevice(Unit, nValue, sValue):
    # Make sure that the Domoticz device still exists (they can be deleted) before updating it 
    if (Unit in Devices):
        if (Devices[Unit].nValue != nValue) or (Devices[Unit].sValue != sValue):
            Devices[Unit].Update(nValue, str(sValue))
            Domoticz.Log("Update "+str(nValue)+":'"+str(sValue)+"' ("+Devices[Unit].Name+")")
    return

    # Generic helper functions
def DumpConfigToLog():
    for x in Parameters:
        if Parameters[x] != "":
            Domoticz.Debug( "'" + x + "':'" + str(Parameters[x]) + "'")
    Domoticz.Debug("Device count: " + str(len(Devices)))
    for x in Devices:
        Domoticz.Debug("Device:           " + str(x) + " - " + str(Devices[x]))
        Domoticz.Debug("Device ID:       '" + str(Devices[x].ID) + "'")
        Domoticz.Debug("Device Name:     '" + Devices[x].Name + "'")
        Domoticz.Debug("Device nValue:    " + str(Devices[x].nValue))
        Domoticz.Debug("Device sValue:   '" + Devices[x].sValue + "'")
        Domoticz.Debug("Device LastLevel: " + str(Devices[x].LastLevel))
    return

def stringToBase64(s):
    return base64.b64encode(s.encode('utf-8')).decode("utf-8")

def base64ToString(b):
    return base64.b64decode(b).decode('utf-8')

As i am not a coder at all I am sure my code is not the most beautifull thing, but it works for me at the moment.

The only thing i am not getting the way it should, is the ON/OFF on the status device :
-On Off action works but the status of the receiver is not 100% clear. --> it appears in the text in the sensor it self
-On Off action works but in some condiftions you need to click a couple of time to cyclus on/off on the device duo to the above.
-Off is displayed as pause, but switches to on while the receiver remains off (due to status update)

I have no idea how to solve this.
- is it possible to retieve the device status in python plugin ? (If i use device.svalue i get errors :S) --> The goal is to stop the commands issued by @MAIN:SOUNDPRG what currently overwrites the status of on/off
- How to put a Kodi like device off and on ?

Any hints tips to solve this last issue are welcome.
Rpi & Win x64. Using : cam's,Nest,RFXCom,Kaku,LaCrosse,RFY,IsAlive,Dummy,Wether Underground, standard Lua, Curl on windows,Domoticz Android App & Tasker,

"The only source of knowledge is experience (A.Einstein)"

mooninite
Posts: 18
Joined: Wednesday 12 July 2017 23:11
Target OS: Linux
Domoticz version: 4.9700
Contact:

Re: Yamaha AV Receiver Plugin

Post by mooninite » Thursday 16 November 2017 6:53

Hello, all.

I have fixed the issue with the switch appearing "on" when the receiver is "off". I have made a pull request with the thomas-villagers github repo and you guys can adapt the patch to your version of Domoticz.

https://github.com/thomas-villagers/dom ... aha/pull/2

thomasvillagers
Posts: 19
Joined: Monday 06 February 2017 16:57
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Yamaha AV Receiver Plugin

Post by thomasvillagers » Friday 17 November 2017 11:28

ah cool! :-) I'll check out your changes later and pull them in if they work ... :-)

- thomas

schulpr
Posts: 116
Joined: Thursday 01 January 2015 10:10
Target OS: NAS (Synology & others)
Domoticz version: Beta
Contact:

Re: Yamaha AV Receiver Plugin

Post by schulpr » Thursday 30 November 2017 21:46

Hi all,

Does anyone has an idea why I get these error messages?

"2017-11-30 19:42:40.856 Error: (Yamaha) Transport is not connected, write directive to 'Yamaha connection' ignored"

I'm on the most recent beta.

Best regards, Rob

woody4165
Posts: 530
Joined: Monday 14 March 2016 14:55
Target OS: Linux
Domoticz version: beta
Location: Rome, Italy
Contact:

Re: Yamaha AV Receiver Plugin

Post by woody4165 » Wednesday 20 December 2017 11:39

Thanks to Thomas for this plugin and to zicht for some mods.

Just removed from zitch plugin everything related to Zone2 and it's working fine with my RX-V479.

Do you think it's possible to select Spotify or BT as source?

Merry Xmas to all of you and thanks again!!!
Cubietruck - Linux cubietruck 4.13.16 (Debian GNU/Linux 8 (jessie)) + Domoticz + RFLink, Xiaomi Gateway, Owl USB, Yeelight Color and B/W, ESP8266, Broadlink RM2, Netatmo Thermostat

getdown
Posts: 8
Joined: Friday 29 December 2017 23:56
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Yamaha AV Receiver Plugin

Post by getdown » Monday 01 January 2018 16:48

Hi All,

I try to use the plugin but in my log i have an error (see the attached file).

Do you know what's the problem ?

happy new year to all !
Attachments
Capture erreur.JPG
Capture erreur.JPG (33.45 KiB) Viewed 1372 times

sion
Posts: 115
Joined: Friday 08 January 2016 13:32
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Yamaha AV Receiver Plugin

Post by sion » Monday 01 January 2018 16:59

HI,
Firstly; Great plugin!
After a day of trying to get this to work - only to realise i had been trying to get it to work ( on windows ) with 64 bit python, i uninstalled that, and instaleld the 32 bit version and all all worked straight away.

SO, everything seems to work well, and got the volume working with alexa which is nice, but my log is filling up with the same message a above:

im getting the following every minuet:

Code: Select all

2018-01-01 14:57:19.331 PluginSystem: Starting I/O service thread.
2018-01-01 14:57:19.436 Error: (lounge AV) 'onMessage' failed 'TypeError':'onMessage() takes 2 positional arguments but 4 were given'.
2018-01-01 14:57:19.436 Error: (lounge AV) 'onMessage' failed 'TypeError':'onMessage() takes 2 positional arguments but 4 were given'.
2018-01-01 14:57:19.436 Error: (lounge AV) 'onMessage' failed 'TypeError':'onMessage() takes 2 positional arguments but 4 were given'.
2018-01-01 14:57:19.436 Error: (lounge AV) 'onMessage' failed 'TypeError':'onMessage() takes 2 positional arguments but 4 were given'.
2018-01-01 14:57:19.441 Error: (lounge AV) 'onMessage' failed 'TypeError':'onMessage() takes 2 positional arguments but 4 were given'.
2018-01-01 14:57:39.420 Error: (lounge AV) 'onMessage' failed 'TypeError':'onMessage() takes 2 positional arguments but 4 were given'.
2018-01-01 14:57:39.420 Error: (lounge AV) 'onMessage' failed 'TypeError':'onMessage() takes 2 positional arguments but 4 were given'.
2018-01-01 14:57:39.426 Error: (lounge AV) 'onMessage' failed 'TypeError':'onMessage() takes 2 positional arguments but 4 were given'.
2018-01-01 14:57:39.429 Error: (lounge AV) 'onMessage' failed 'TypeError':'onMessage() takes 2 positional arguments but 4 were given'.
2018-01-01 14:57:39.431 Error: (lounge AV) 'onMessage' failed 'TypeError':'onMessage() takes 2 positional arguments but 4 were given'
did anyone find a fix for this?

CHeers,
Sion.
running domoticz 3.4834 on rpi2, with
Hue bridge / bulbs.
lightwave rf sockets, mood controlers, sensors & contacts.
Home bridge / Siri.
Ha bridge / echo Alexa.
Hard wired alarm system - setting home / away status.

Next: harmony hub.

sion
Posts: 115
Joined: Friday 08 January 2016 13:32
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Yamaha AV Receiver Plugin

Post by sion » Monday 01 January 2018 17:28

Spoke too soon ;)
After aboit 30 mins it crashed Domoticz .
It’s now crashing domoticz as soon as it loads.

Using windows 10.
Latest stable build.
Latest python 32bit.

I also tried this with the latest beta, but it crashed as soon as I adjusted volume.

How do I go about disabeling it if I can’t get domoticz to load?
running domoticz 3.4834 on rpi2, with
Hue bridge / bulbs.
lightwave rf sockets, mood controlers, sensors & contacts.
Home bridge / Siri.
Ha bridge / echo Alexa.
Hard wired alarm system - setting home / away status.

Next: harmony hub.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests