Skip to content

Commit

Permalink
Release 1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
msinn committed Apr 5, 2020
2 parents fe5c3ea + 21244b3 commit 0fa4926
Show file tree
Hide file tree
Showing 1,117 changed files with 76,266 additions and 165,302 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,7 @@ Thumbs.db

# Pycharm settings
/.idea
/.vs

# VSCode settings
.vscode/settings.json
15 changes: 8 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
sudo: false
os: linux
language: python

matrix:
jobs:
include:
- python: 3.4
- python: 3.5
dist: xenial
- python: 3.6
dist: bionic
- python: 3.7
dist: xenial

dist: bionic
env:
- REPOSITORY_ORIGIN=plugins

YARN_GPG=no
before_install:
- sudo apt-get install libudev-dev
- sudo apt-get install librrd-dev libpython3-dev
install:
- pip install tox-travis "virtualenv<14.0.0"
- pip install tox-travis virtualenv

script:
- sh .travis.sh
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# SmartHomeNG plugins

[![Build Status on TravisCI](https://travis-ci.org/smarthomeNG/plugins.svg?branch=develop)](https://travis-ci.org/smarthomeNG/plugins)
[![Join the chat at https://gitter.im/smarthomeNG/smarthome](https://badges.gitter.im/smarthomeNG/smarthome.svg)](https://gitter.im/smarthomeNG/smarthome?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

Plugins for SmartHomeNG interconnect multiple devices to access their specific interfaces and extend the possibilities of the whole system.

Developer documentation ([english](https://www.smarthomeNG.de/dev)) and user documentation ([german](https://www.smarthomeNG.de/user)) can be found on [www.smarthomeNG.de](https://www.smarthomeNG.de)

Additional information / documentation can be found in the [SmartHomeNG Wiki](https://github.com/smarthomeNG/smarthome/wiki).
The Wiki is written in german for the greatest part.
2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
def plugin_release():
return '1.6'
return '1.7'


def plugin_branch():
Expand Down
106 changes: 53 additions & 53 deletions alexa4p3/p3_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,26 @@ def SetThermostatMode(self, directive):
# define Mode-Lists
device_id = directive['endpoint']['endpointId']
items = self.items(device_id)

AlexaItem = self.devices.get(device_id)
myModes = AlexaItem.thermo_config
myValueList = self.GenerateThermoList(myModes,1)
myModeList = self.GenerateThermoList(myModes,2)

# End of Modes-List
new_Mode = directive['payload']['thermostatMode']['value']


new_Mode = directive['payload']['thermostatMode']['value']



item_new = myModeList[new_Mode]
for item in items:
self.logger.info("Alexa: SetThermostatMode({}, {})".format(item.id(), item_new))
item( item_new )
item( item_new, "alexa4p3" )

#new_temp = items[0]() if items else 0

self.response_Value = new_Mode
myValue = self.p3_respond(directive)
return myValue
Expand All @@ -84,18 +84,18 @@ def AdjustTargetTemperature(self, directive):
item_range = self.item_range(item, DEFAULT_TEMP_RANGE)
item_new = clamp_temp(previous_temp + delta_temp, item_range)
self.logger.info("Alexa: AdjustTargetTemperature({}, {:.1f})".format(item.id(), item_new))
item( item_new )
item( item_new, "alexa4p3" )

new_temp = items[0]() if items else 0

self.response_Value = None
self.response_Value = {
"value": new_temp,
"scale": "CELSIUS"
}
myValue = self.p3_respond(directive)
return myValue

@alexa('SetTargetTemperature', 'SetTargetTemperature', 'targetSetpoint','Alexa.ThermostatController',['SetThermostatMode'])
def SetTargetTemperature(self, directive):
device_id = directive['endpoint']['endpointId']
Expand All @@ -108,18 +108,18 @@ def SetTargetTemperature(self, directive):
item_range = self.item_range(item, DEFAULT_TEMP_RANGE)
item_new = clamp_temp(target_temp, item_range)
self.logger.info("Alexa: SetTargetTemperature({}, {:.1f})".format(item.id(), item_new))
item( item_new )
item( item_new, "alexa4p3" )

new_temp = items[0]() if items else 0

self.response_Value = None
self.response_Value = {
"value": new_temp,
"scale": "CELSIUS"
}
myValue = self.p3_respond(directive)
return myValue



# Alexa PowerController
Expand All @@ -133,7 +133,7 @@ def TurnOn(self, directive):
on, off = self.item_range(item, DEFAULT_RANGE_LOGIC)
self.logger.info("Alexa: turnOn({}, {})".format(item.id(), on))
if on != None:
item( on )
item( on, "alexa4p3" )
self.response_Value = 'ON'
myValue = self.p3_respond(directive)
return myValue
Expand All @@ -147,7 +147,7 @@ def TurnOff(self, directive):
on, off = self.item_range(item, DEFAULT_RANGE_LOGIC)
self.logger.info("Alexa: turnOff({}, {})".format(item.id(), off))
if off != None:
item( off )
item( off, "alexa4p3" )
self.response_Value = 'OFF'
return self.p3_respond(directive)

Expand All @@ -163,10 +163,10 @@ def Lock(self, directive):
on, off = self.item_range(item, DEFAULT_RANGE_LOGIC)
self.logger.info("Alexa: Lock({}, {})".format(item.id(), on))
if on != None:
item( on )
item( on, "alexa4p3" )
self.response_Value = None
self.response_Value = 'LOCKED'

return self.p3_respond(directive)

@alexa('Unlock', 'Unlock', 'lockState','Alexa.LockController',[])
Expand All @@ -178,20 +178,20 @@ def Unlock(self, directive):
on, off = self.item_range(item, DEFAULT_RANGE_LOGIC)
self.logger.info("Alexa: Unlock({}, {})".format(item.id(), off))
if off != None:
item( on )
item( on, "alexa4p3" )
self.response_Value = None
self.response_Value = 'UNLOCKED'

return self.p3_respond(directive)


# Alexa-Brightness-Controller
# Alexa-Brightness-Controller

@alexa('AdjustBrightness', 'AdjustBrightness', 'brightness','Alexa.BrightnessController',[])
def AdjustBrightness(self, directive):
device_id = directive['endpoint']['endpointId']
items = self.items(device_id)

percentage_delta = float( directive['payload']['brightnessDelta'] )

for item in items:
Expand All @@ -201,10 +201,10 @@ def AdjustBrightness(self, directive):
percentage_new = clamp_percentage(percentage_now + percentage_delta, item_range)
item_new = calc_percentage(percentage_new, item_range)
self.logger.info("Alexa P3: AdjustBrightness({}, {:.1f})".format(item.id(), item_new))
item( item_new )
item( item_new, "alexa4p3" )
self.response_Value = None
self.response_Value = int(percentage_new)

return self.p3_respond(directive)

@alexa('SetBrightness', 'SetBrightness', 'brightness','Alexa.BrightnessController',[])
Expand All @@ -217,7 +217,7 @@ def SetBrightness(self, directive):
item_range = self.item_range(item, DEFAULT_RANGE)
item_new = calc_percentage(new_percentage, item_range)
self.logger.info("Alexa P3: SetBrightness({}, {:.1f})".format(item.id(), item_new))
item( item_new )
item( item_new, "alexa4p3" )
self.response_Value = None
self.response_Value = int(new_percentage)

Expand All @@ -231,7 +231,7 @@ def SetBrightness(self, directive):
def AdjustPercentage(self, directive):
device_id = directive['endpoint']['endpointId']
items = self.items(device_id)

percentage_delta = float( directive['payload']['percentageDelta'] )

for item in items:
Expand All @@ -241,12 +241,12 @@ def AdjustPercentage(self, directive):
percentage_new = clamp_percentage(percentage_now + percentage_delta, item_range)
item_new = calc_percentage(percentage_new, item_range)
self.logger.info("Alexa P3: AdjustPercentage({}, {:.1f})".format(item.id(), item_new))
item( item_new )
item( item_new, "alexa4p3" )
self.response_Value = None
self.response_Value = int(percentage_new)

return self.p3_respond(directive)

@alexa('SetPercentage', 'SetPercentage', 'percentage','Alexa.PercentageController',[])
def SetPercentage(self, directive):
device_id = directive['endpoint']['endpointId']
Expand All @@ -257,10 +257,10 @@ def SetPercentage(self, directive):
item_range = self.item_range(item, DEFAULT_RANGE)
item_new = calc_percentage(new_percentage, item_range)
self.logger.info("Alexa P3: SetPercentage({}, {:.1f})".format(item.id(), item_new))
item( item_new )
item( item_new, "alexa4p3" )
self.response_Value = None
self.response_Value = int(new_percentage)

return self.p3_respond(directive)


Expand All @@ -270,7 +270,7 @@ def SetPercentage(self, directive):
def AdjustPowerLevel(self, directive):
device_id = directive['endpoint']['endpointId']
items = self.items(device_id)

percentage_delta = float( directive['payload']['powerLevelDelta'] )

for item in items:
Expand All @@ -280,10 +280,10 @@ def AdjustPowerLevel(self, directive):
percentage_new = clamp_percentage(percentage_now + percentage_delta, item_range)
item_new = calc_percentage(percentage_new, item_range)
self.logger.info("Alexa P3: AdjustPowerLevel({}, {:.1f})".format(item.id(), item_new))
item( item_new )
item( item_new, "alexa4p3" )
self.response_Value = None
self.response_Value = int(percentage_new)

return self.p3_respond(directive)

@alexa('SetPowerLevel', 'SetPowerLevel', 'powerLevel','Alexa.PowerLevelController',[])
Expand All @@ -296,10 +296,10 @@ def SetPowerLevel(self, directive):
item_range = self.item_range(item, DEFAULT_RANGE)
item_new = calc_percentage(new_percentage, item_range)
self.logger.info("Alexa P3: SetPowerLevel({}, {:.1f})".format(item.id(), item_new))
item( item_new )
item( item_new, "alexa4p3" )
self.response_Value = None
self.response_Value = int(new_percentage)

return self.p3_respond(directive)


Expand All @@ -315,10 +315,10 @@ def Activate(self, directive):
on, off = self.item_range(item, DEFAULT_RANGE_LOGIC)
item_new = on # Should be the No. of the Scene
self.logger.info("Alexa P3: Activate Scene ({}, {})".format(item.id(), item_new))
item( item_new )
item( item_new, "alexa4p3" )
self.response_Value = None
self.response_Value = item_new

return self.p3_respond(directive)


Expand All @@ -334,19 +334,19 @@ def Stop(self, directive):


for item in items:
item_new = 1
item_new = 1
self.logger.info("Alexa P3: PBC Stop received ({}, {})".format(item.id(), item_new))
item( item_new )
item( item_new, "alexa4p3" )
self.response_Value = None
self.response_Value = item_new

return self.p3_respond(directive)


# CameraStreamController
@alexa('InitializeCameraStreams', 'InitializeCameraStreams', 'cameraStreamConfigurations','Alexa.CameraStreamController',[])
def InitializeCameraStreams(self, directive):

p3tools.DumpStreamInfo(directive)
device_id = directive['endpoint']['endpointId']
items = self.items(device_id)
Expand Down Expand Up @@ -390,19 +390,19 @@ def SetColor(self, directive):
r,g,b = p3tools.hsv_to_rgb(new_hue,new_saturation,new_brightness)
except Exception as err:
self.logger.error("Alexa P3: SetColor Calculate to RGB failed ({}, {})".format(item.id(), err))

retValue=[]
retValue.append(r)
retValue.append(g)
retValue.append(b)

device_id = directive['endpoint']['endpointId']
items = self.items(device_id)



for item in items:

if 'alexa_color_value_type' in item.conf:
colortype = item.conf['alexa_color_value_type']
if colortype == 'HSB':
Expand All @@ -417,12 +417,12 @@ def SetColor(self, directive):
retValue.append(1.0)
else:
retValue.append(new_brightness)

self.logger.info("Alexa P3: SetColor ({}, {})".format(item.id(), str(retValue)))
item( retValue )
item( retValue, "alexa4p3" )
self.response_Value = None
self.response_Value = directive['payload']['color']

return self.p3_respond(directive)


Expand Down
Loading

0 comments on commit 0fa4926

Please sign in to comment.