diff --git a/modules/domoticz.py b/modules/domoticz.py index 55a786d..47a1c14 100644 --- a/modules/domoticz.py +++ b/modules/domoticz.py @@ -354,6 +354,7 @@ def getAog(device, user_id=None): ], 'cameraStreamNeedAuthToken': False } + if domain in ['OnOff'] and aog.type in ['action.devices.types.HEATER', 'action.devices.types.WATERHEATER', 'action.devices.types.KETTLE', 'action.devices.types.OVEN']: if 'merge_thermo_idx' in aog.customData: aog.traits.append('action.devices.traits.TemperatureControl') @@ -369,7 +370,7 @@ def getAog(device, user_id=None): aog.attributes['commandOnlyTimer'] = True batteryLevel = device.get('BatteryLevel') - if domain not in ['Group', 'Scene'] and batteryLevel != 255: + if domain not in ['Group', 'Scene'] and batteryLevel is not None and batteryLevel != 255: aog.traits.append('action.devices.traits.EnergyStorage') aog.attributes['queryOnlyEnergyStorage'] = True aog.attributes['isRechargeable'] = False diff --git a/modules/trait.py b/modules/trait.py index 60c7577..8b90e6b 100644 --- a/modules/trait.py +++ b/modules/trait.py @@ -130,9 +130,9 @@ def query(custom_data, device, user_id): response["currentArmLevel"] = state['Data'] if 'action.devices.traits.EnergyStorage' in device['traits']: - if state['BatteryLevel'] != 255: + if state['BatteryLevel'] is not None: battery = state['BatteryLevel'] - if battery is not None: + if battery != 255: if battery >= 100: descriptive_capacity_remaining = "FULL" elif 50 <= battery < 100: @@ -151,7 +151,7 @@ def query(custom_data, device, user_id): }] response['online'] = True - if domain not in ['Group', 'Scene'] and state['BatteryLevel'] != 255: + if domain not in ['Group', 'Scene'] and state['BatteryLevel'] is not None and state['BatteryLevel'] != 255: if state['BatteryLevel'] <= 10: # Report low battery below 10% response['exceptionCode'] = 'lowBattery' @@ -351,6 +351,14 @@ def execute(device, command, params, user_id, challenge): slevel = str(levelName.index(key) * 10) url += 'switchlight&idx=' + idx + '&switchcmd=Set%20Level&level=' + slevel + + if command == 'action.devices.commands.TimerStart': + + url += 'customevent&event=TIMER&data={"idx":' + idx + ',"time":' + str(params['timerTimeSec']) + ',"on":true}' + + if command == 'action.devices.commands.TimerCancel': + + url += 'customevent&event=TIMER&data={"idx":' + idx + ',"cancel":true}' if command == 'action.devices.commands.TimerStart': diff --git a/static/js/smarthome.js b/static/js/smarthome.js index 0e3e5f6..8387c0e 100644 --- a/static/js/smarthome.js +++ b/static/js/smarthome.js @@ -365,17 +365,6 @@ function setSelectorLevel(div, idx, protect) { requestAPI(requesturl) } -function getUser(user) { - var url = "/api?type=command¶m=getusers" - requestAPI(url).then(jsonData => { - var data = jsonData - if (data.status == 'ERR' || data.status == null) { - $('#domoticzAdmin').val('No') - } else { - $('#domoticzAdmin').val('Yes') - } - }); -} function getDzVersion() { var url = "/api?type=command¶m=getversion" requestAPI(url).then(jsonData => { diff --git a/templates/settings.html b/templates/settings.html index b2cb1c8..4ca42fd 100644 --- a/templates/settings.html +++ b/templates/settings.html @@ -73,7 +73,7 @@