Skip to content

Commit

Permalink
Merge branch 'development' into DewGew-patch-2
Browse files Browse the repository at this point in the history
  • Loading branch information
DewGew authored Feb 11, 2024
2 parents 323921e + 03c6e9d commit 74bad48
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 18 deletions.
3 changes: 2 additions & 1 deletion modules/domoticz.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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
Expand Down
14 changes: 11 additions & 3 deletions modules/trait.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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'

Expand Down Expand Up @@ -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':

Expand Down
11 changes: 0 additions & 11 deletions static/js/smarthome.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,17 +365,6 @@ function setSelectorLevel(div, idx, protect) {
requestAPI(requesturl)
}

function getUser(user) {
var url = "/api?type=command&param=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&param=getversion"
requestAPI(url).then(jsonData => {
Expand Down
4 changes: 1 addition & 3 deletions templates/settings.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ <h5 class="card-title">User settings <span>| {{ user.username }}</span></h5>
</div>
<div class="col-md-6" >
<label for="domoticzAdmin" class="form-label">Domoticz Admin</label>
<input type="text" class="form-control" id="domoticzAdmin" value="No" disabled readonly>
<input type="text" class="form-control" id="domoticzAdmin" value="{% if dzUserAdmin is true %}Yes{% else %}No{% endif %}" disabled readonly>
</div>
<div class="col-md-12" id="div_token">
<label for="token" class="form-label">Auth Token</label>
Expand Down Expand Up @@ -126,6 +126,4 @@ <h5 class="card-title">User settings <span>| {{ user.username }}</span></h5>
}
});

getUser("{{ user.domouser }}")

</script>

0 comments on commit 74bad48

Please sign in to comment.