no plugins directory? Topic is solved

Python and python framework

Moderator: leecollings

Post Reply
giova
Posts: 7
Joined: Sunday 22 January 2017 21:27
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

no plugins directory?

Post by giova »

I've installed domoticz Version: 3.5877 Build Hash: 15b013c on my raspberry pi3 few weeks ago.
I try to do my baby steps first plugin following the wiki help page.

But there is no plugins directory into my domoticz (/etc/domoticz) !
is that normal?

ok, i've created the folder, gived access to pi user and made my first plugin /etc/domoticz/plugins/myplugin.py

but even after reboot it is not displayed in settings->material

I'm little bit lost so. Here my code , any help would be really appreciated !

Code: Select all

#
#       Windows Screen Remote
#
#       Author:     Giova, 2017
#
#   let Domoticz remotely control your Windows PC Screen (turn On/Off)
#
"""
<plugin key="WinScreenRemote" version="1.0.0" name="Windows Screen Remote" author="Giova" >
    <params>
        <param field="Address" label="IP Address" width="200px" required="true" default="192.168.0.1"/>
        <param field="Port" label="Port" width="30px" required="true" default="5553"/>
        <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

isConnected = False
isStarting = False
nextConnect = 3
oustandingPings = 0

# Device Status - When off set device values to negative
powerOn = False

def onStart():
    if Parameters["Mode6"] == "Debug":
        Domoticz.Debugging(1)
    if (len(Devices) == 0):
        Domoticz.Device(Name="Screen Power",   Unit=1, TypeName="Switch").Create()
        Domoticz.Log("Devices created.")
    DumpConfigToLog()
    Domoticz.Transport("TCP/IP", Parameters["Address"], Parameters["Port"])
    Domoticz.Protocol("Line")
    Domoticz.Connect()
    return

def onConnect(Status, Description):
    global isConnected
    if (Status == 0):
        isConnected = True
        Domoticz.Log("Connected successfully to: "+Parameters["Address"]+":"+Parameters["Port"])
        Domoticz.Send('PW?\r')
    else:
        isConnected = False
        Domoticz.Log("Failed to connect ("+str(Status)+") to: "+Parameters["Address"]+":"+Parameters["Port"])
        Domoticz.Debug("Failed to connect ("+str(Status)+") to: "+Parameters["Address"]+":"+Parameters["Port"]+" with error: "+Description)
        # Turn devices off in Domoticz
        for Key in Devices:
            UpdateDevice(Key, 0, Devices[Key].sValue)
    return True

def onMessage(Data, Status, Extra):
    global oustandingPings, isStarting
    global  powerOn

    oustandingPings = oustandingPings - 1
    Domoticz.Debug("onMessage ("+str(isStarting)+") called with Data: '"+str(Data)+"'")
    
    Data = Data.strip()
    action = Data[0:2]
    detail = Data[2:]

    if (action == "PW"):        # Power Status
        if (detail == "Off"):
            powerOn = False
        elif (detail == "On"):
            powerOn = True
        else: Domoticz.Debug("Unknown: Action "+action+", Detail '"+detail+"' ignored.")
    else:
        Domoticz.Error("Unknown message '"+action+"' ignored.")
    SyncDevices()
    return

def onCommand(Unit, Command, Level, Hue):
    global powerOn

    Domoticz.Log("onCommand called for Unit " + str(Unit) + ": Parameter '" + str(Command) + "', Level: " + str(Level))

    Command = Command.strip()
    action, sep, params = Command.partition(' ')
    if (powerOn == False):
        Domoticz.Send('PWON\r')  # Any commands sent within 4 seconds of this will potentially be ignored
    else:
        if (action == "On"):
            if (Unit == 1):     Domoticz.Send('PWON\r')
            else: Domoticz.Error( "Unknown Unit number in command "+str(Unit)+".")
        elif (action == "Off"):
            if (Unit == 1):     Domoticz.Send('PWOFF\r')
            else: Domoticz.Error( "Unknown Unit number in command "+str(Unit)+".")
        else:
            Domoticz.Error("Unhandled action '"+action+"' ignored, options are On/Set/Off")
    return

def onDisconnect():
    global isConnected, powerOn

    isConnected = False
    powerOn = False
    Domoticz.Log("Device has disconnected.")
    SyncDevices()
    return

def onStop():
    Domoticz.Log("onStop called")
    return 8

def onHeartbeat():
    global isConnected, nextConnect, oustandingPings
    if (isConnected == True):
        if (oustandingPings > 5):
            Domoticz.Disconnect()
            nextConnect = 0
        else:
            Domoticz.Send('PW?\r')
            oustandingPings = oustandingPings + 1
    else:
        # if not connected try and reconnected every 3 heartbeats
        oustandingPings = 0
        nextConnect = nextConnect - 1
        if (nextConnect <= 0):
            nextConnect = 3
            Domoticz.Connect()
    return

def SyncDevices():
    global powerOn
    
    if (powerOn == False):
        UpdateDevice(1, 0, "Off")
    else:
        UpdateDevice(1, 1, "On")
    return

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

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
User avatar
G3rard
Posts: 669
Joined: Wednesday 04 March 2015 22:15
Target OS: -
Domoticz version: No
Location: The Netherlands
Contact:

Re: no plugins directory?

Post by G3rard »

You installed the stable version. Python plugin is available in latest beta versions.
Not using Domoticz anymore
giova
Posts: 7
Joined: Sunday 22 January 2017 21:27
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: no plugins directory?

Post by giova »

thank you for that fast answer.

ok i do a backup then i'll try updatebeta script
giova
Posts: 7
Joined: Sunday 22 January 2017 21:27
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: no plugins directory?

Post by giova »

Well... i've compiled python-plugin branch from github (v3.6500)

Now i have plugin directory with all examples, but i hardware page still not displaying plugins

Beta is selected in settings
i also placed my plugin like this :
/etc/domoticz/plugins/Myplugin/Myplugin.py

What have i done wrong?
User avatar
G3rard
Posts: 669
Joined: Wednesday 04 March 2015 22:15
Target OS: -
Domoticz version: No
Location: The Netherlands
Contact:

no plugins directory?

Post by G3rard »

The plugin must be called plugin.py
Please search the forum and wiki, all info is there.
Not using Domoticz anymore
User avatar
G3rard
Posts: 669
Joined: Wednesday 04 March 2015 22:15
Target OS: -
Domoticz version: No
Location: The Netherlands
Contact:

Re: no plugins directory?

Post by G3rard »

@giova, did you get the plugin working?
I tried the plugin on Domoticz v.3.6544 but it's not loading. Seems an interesting plugin, so I curious if you got any further with it.
Not using Domoticz anymore
Quax1507
Posts: 101
Joined: Tuesday 07 April 2015 21:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: no plugins directory?

Post by Quax1507 »

I upgraded to beta 6561. No plugins directory found!
What am I doing wrong?
jrt4fun
Posts: 2
Joined: Friday 03 February 2017 8:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: no plugins directory?

Post by jrt4fun »

Seem to have the same issue.
I upgraded to beta version V3.6588
When looking in /home/pi/domoticz there is no plugins directory
I created one and added the plugin as mentioned in the wiki (subdir with plugin.py) still it is not showing up in the hardware on reboot.
I set permissions as well on the new folders.

any thoughts or hints to get it working?
RayAmsterdam
Posts: 115
Joined: Sunday 11 January 2015 16:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: no plugins directory?

Post by RayAmsterdam »

I had the same problem. It seemed libpython3.x wasn't installed.
Have a look at http://www.domoticz.com/wiki/Linux#Prob ... ing_Python .
jrt4fun
Posts: 2
Joined: Friday 03 February 2017 8:40
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: no plugins directory?

Post by jrt4fun »

Ray,

thank you for the tip.
It worked flawless !!!
sweup
Posts: 37
Joined: Friday 19 February 2016 13:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: no plugins directory?

Post by sweup »

Hi, i installed python (sudo apt-get install libpython3.4) but no plugin folder for me. Is there anything more that needs to be done?

Edit: seams that 2.7.9 us running. I dont understand second step: set (python_additional..)

Sry for noob question, but how should i wrote the proper command?
User avatar
gizmocuz
Posts: 2546
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: no plugins directory?

Post by gizmocuz »

In the archive generator, the plugin folder was not included yet.
This is now added in the next beta
Quality outlives Quantity!
sweup
Posts: 37
Joined: Friday 19 February 2016 13:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: no plugins directory?

Post by sweup »

Thanks for reply, looking forward for this
strixx
Posts: 16
Joined: Tuesday 04 October 2016 11:21
Target OS: -
Domoticz version:
Contact:

Re: no plugins directory?

Post by strixx »

Updated today to the latest stable (3.8153) to be able to install plugins.
And the folder /plugins is still not created. I had to do it manually.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest