Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Roller blind E1766 and E1757 are now managed as percent roller blind #223

Merged
merged 1 commit into from
Jan 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 19 additions & 16 deletions adapters/ikea/tradfri_roller_blind.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
import json
from adapters.base_adapter import Adapter
from devices.switch.selector_switch import SelectorSwitch

from devices.switch.blind_percentages_switch import BlindSwitch

class TradfriRollerBlind(Adapter):
def __init__(self, devices):
super().__init__(devices)

self.switch = SelectorSwitch(devices, 'switch', 'click')
self.switch.add_level('Up', 'open')
self.switch.add_level('Down', 'close')

self.devices.append(self.switch)
self.devices.append(BlindSwitch(devices, 'dimmer', 'position'))

def handleCommand(self, alias, device, device_data, command, level, color):
self.switch.handle_command(device_data, command, level, color)

if (command.upper() == "ON"):
command="close"
if (command.upper() == "SET LEVEL"):
return {
'topic': device_data['friendly_name'] + '/set',
'payload': json.dumps({
"position": int(100-level)
})
}
elif (command.upper() == "ON"):
return {
'topic': device_data['friendly_name'] + '/set',
'payload': json.dumps({
"state": "close"
})
}
else:
command="open"

return {
return {
'topic': device_data['friendly_name'] + '/set',
'payload': json.dumps({
"state": command.upper()
"state": "open"
})
}
}
19 changes: 19 additions & 0 deletions devices/switch/blind_percentages_switch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Domoticz
from devices.device import Device


class BlindSwitch(Device):
def create_device(self, unit, device_id, device_name):
return Domoticz.Device(Unit=unit, DeviceID=device_id, Name=device_name, Type=244, Subtype=73, Switchtype=13).Create()

def get_numeric_value(self, value, device):
if (value==100):
return 0
elif (value==0):
return 1
else:
return 2

def get_string_value(self, value, device):
return str(int(100-value))