Skip to content

Commit

Permalink
Merge pull request #90 from DewGew/devetypes
Browse files Browse the repository at this point in the history
Devetypes
  • Loading branch information
DewGew authored Feb 2, 2024
2 parents 919fafe + 4ff87f7 commit e1eed48
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 46 deletions.
11 changes: 6 additions & 5 deletions VERSION.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
24.5
- Fix for blinds graphics in UI
- Fixes Lighting 4 devices
- Added battery level on dashboard devices
- Added Enerygystorgae trait uses to check battery level
24.6
- Fixed "Deprecated RType () for API request" error
- Fixed camerastream not working
- Add Security device
- UI improvments
- Add more selectable device types
14 changes: 9 additions & 5 deletions modules/domoticz.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,17 @@ def getAog(device, user_id=None):
aog.type = 'action.devices.types.FAN'
if device.get('Image') == 'Heating':
aog.type = 'action.devices.types.HEATER'

if domain in ['Temp', 'TempHumidity', 'TempHumidityBaro', 'DoorContact', 'Contact']:
aog.type = 'action.devices.types.SENSOR'
if domain in ['Thermostat', 'Setpoint']:
aog.type = 'action.devices.types.THERMOSTAT'
if domain in ['VenetianBlindsUS', 'VenetianBlindsEU', 'Blinds', 'BlindsStop', 'BlindsPercentage']:
aog.type = 'action.devices.types.BLINDS'
if domain in ['Selector']:
aog.type = 'action.devices.types.SWITCH'
if domain in ['DoorLock', 'DoorLockInverted']:
aog.type = 'action.devices.types.LOCK'

# Try to get device specific voice control configuration from Domoticz
aog.customData['dzTags'] = False
Expand Down Expand Up @@ -221,11 +230,9 @@ def getAog(device, user_id=None):
if domain == 'Dimmer':
aog.traits.append('action.devices.traits.Brightness')
if domain in ['DoorLock', 'DoorLockInverted']:
aog.type = 'action.devices.types.LOCK'
aog.traits.append('action.devices.traits.LockUnlock')

if domain in ['VenetianBlindsUS', 'VenetianBlindsEU', 'Blinds', 'BlindsStop', 'BlindsPercentage']:
aog.type = 'action.devices.types.BLINDS'
aog.traits.append('action.devices.traits.OpenClose')
if domain in ['VenetianBlindsUS', 'VenetianBlindsEU', 'BlindsStop']:
aog.traits.append('action.devices.traits.StartStop')
Expand All @@ -242,7 +249,6 @@ def getAog(device, user_id=None):
'temperatureMaxK': 6500}
}
if domain == 'Selector':
aog.type = 'action.devices.types.SWITCH'
aog.traits.append('action.devices.traits.OnOff')
aog.traits.append('action.devices.traits.Toggles')
levelName = base64.b64decode(device.get("LevelNames")).decode('UTF-8').split("|")
Expand Down Expand Up @@ -294,7 +300,6 @@ def getAog(device, user_id=None):
# <-- Modes trait for selector not working yet

if domain in ['Temp', 'TempHumidity', 'TempHumidityBaro']:
aog.type = 'action.devices.types.SENSOR'
aog.traits.append('action.devices.traits.TemperatureSetting')
aog.attributes = {'thermostatTemperatureUnit': dbsettings.tempunit,
'thermostatTemperatureRange': {
Expand Down Expand Up @@ -323,7 +328,6 @@ def getAog(device, user_id=None):
"occupancySensorType": "PIR",
}]}
if domain in ['DoorContact', 'Contact']:
aog.type = 'action.devices.types.SENSOR'
aog.traits.append('action.devices.traits.OpenClose')
aog.attributes = {'discreteOnlyOpenClose': True,
'queryOnlyOpenClose': True}
Expand Down
20 changes: 14 additions & 6 deletions templates/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -211,20 +211,28 @@ <h5 class="card-title">Device log <span>| {{ v['name']['name'] }}</span></h5>
</div>
</div>

{% elif v['customData']['domain'] in ('VenetianBlindsUS', 'VenetianBlindsEU', 'Blinds', 'BlindsStop','BlindsPercentage')%}
{% elif v['customData']['domain'] in ('VenetianBlindsUS', 'VenetianBlindsEU', 'Blinds', 'BlindsStop', 'BlindsPercentage')%}
<div class="icon">
<i class="material-symbols-outlined" id="icon_blinds_{{ v['customData']['idx'] }}">roller_shades</i>
<small id="data_{{ v['customData']['idx'] }}">Not available</small>
<div class="label">{{ v['name']['name'] }}</div>
{% if v['customData']['domain'] != 'BlindsPercentage' %}
<div class="btn-group" role="group" aria-label="Basic outlined blinds">
{% if v['customData']['domain'] in ['VenetianBlindsUS', 'VenetianBlindsEU', 'Blinds', 'BlindsStop'] %}
<div class="btn-group d-none d-sm-block" role="group" aria-label="Basic outlined blinds">
<button type="button" class="btn btn-outline-primary btn-sm" onclick="openCloseBlind({{ v['customData']['idx'] }}, 'Open')"><i class="bi bi-arrow-up-circle" style="font-size: 1rem;"></i></button>
{% if v['customData']['domain'] != 'Blinds' %}
<button type="button" class="btn btn-outline-primary btn-sm" onclick="openCloseBlind({{ v['customData']['idx'] }}, 'Stop')"><i class="bi bi-stop-circle" style="font-size: 1rem; color: red;"></i></button>
{% endif %}
<button type="button" class="btn btn-outline-primary btn-sm" onclick="openCloseBlind({{ v['customData']['idx'] }}, 'Close')"><i class="bi bi-arrow-down-circle" style="font-size: 1rem;"></i></button>
</div>
{% else %}
<div class="btn-group d-block d-sm-none" role="group" aria-label="Basic outlined blinds">
<button type="button" class="btn btn-outline-primary btn-lg" onclick="openCloseBlind({{ v['customData']['idx'] }}, 'Open')"><i class="bi bi-arrow-up-circle" style="font-size: 1rem;"></i></button>
{% if v['customData']['domain'] != 'Blinds' %}
<button type="button" class="btn btn-outline-primary btn-lg" onclick="openCloseBlind({{ v['customData']['idx'] }}, 'Stop')"><i class="bi bi-stop-circle" style="font-size: 1rem; color: red;"></i></button>
{% endif %}
<button type="button" class="btn btn-outline-primary btn-lg" onclick="openCloseBlind({{ v['customData']['idx'] }}, 'Close')"><i class="bi bi-arrow-down-circle" style="font-size: 1rem;"></i></button>
</div>
{% endif %}
{% if v['customData']['domain'] in ['BlindsStop', 'BlindsPercentage'] %}
<input id="slider_{{ v['customData']['idx'] }}" type="range" min="0" max="100" step="1" onchange="changeDimmers({{ v['customData']['idx'] }}, this.value, '{{ v['customData']['protected'] }}')">
{% endif %}
<div class="card-footer col-sm-12">
Expand Down Expand Up @@ -803,7 +811,7 @@ <h5 id="title_other">Other devices <small>(not supported devices)</small><i clas
$("#icon_{{ v['customData']['domain'] }}_{{ v['customData']['idx'] }}").addClass("bi bi-toggle2-off").removeAttr('style');
}, 2000);
});
{% elif v['customData']['domain'] in ('Dimmer', 'ColorSwitch', 'BlindsPercentage') %}
{% elif v['customData']['domain'] in ('Dimmer', 'ColorSwitch', 'BlindsStop', 'BlindsPercentage') %}
updateDimmers_block.push("{{ v['customData']['idx'] }}")
$('#title_switches').show()
{% elif v['customData']['domain'] in ['Selector', 'Selector_Hidden'] %}
Expand All @@ -818,7 +826,7 @@ <h5 id="title_other">Other devices <small>(not supported devices)</small><i clas
$('#title_security').show()
$("#title_security > i").toggleClass('bi bi-chevron-compact-up')
{% elif (v['customData']['domain'] not in (
'SmokeDetector', 'Security', 'VenetianBlindsEU', 'OnOff', 'VenetianBlindsUS', 'Doorbell', 'DoorLock', 'DoorLockInverted', 'DoorContact', 'BlindsPercentage',
'SmokeDetector', 'Security', 'VenetianBlindsEU', 'OnOff', 'VenetianBlindsUS', 'Doorbell', 'DoorLock', 'DoorLockInverted', 'DoorContact', 'BlindsStop', 'BlindsPercentage',
'MotionSensor', 'PushOnButton', 'PushOffButton', 'Contact') and 'Hidden' not in v['customData']['domain']) %}
updateOthers_block.push("{{ v['customData']['idx'] }}")
$('#title_other').show()
Expand Down
Loading

0 comments on commit e1eed48

Please sign in to comment.