Skip to content

Commit

Permalink
Merge pull request #78 from DewGew/DewGew-patch-2
Browse files Browse the repository at this point in the history
Security fix, added door lock inverted
  • Loading branch information
DewGew authored Jan 29, 2024
2 parents 31d4bca + 5e84a2b commit 01053ab
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 13 deletions.
5 changes: 4 additions & 1 deletion VERSION.md
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
24.1
24.2
- Security Update. DZGA now reads smart-home-key.json file from config folder. Move .json file or upload a new.
- Added new device, Door Lock Inverted.
- Changed check version, get latest updates.
2 changes: 1 addition & 1 deletion modules/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
DEVICES_DIRECTORY = "config"
KEYFILE_DIRECTORY = "uploads"
KEYFILE_DIRECTORY = "config"
CONFIG_DIRECTORY = "config"
UPLOAD_DIRECTORY = "uploads"
DATABASE_DIRECTORY = "instance"
Expand Down
4 changes: 2 additions & 2 deletions modules/domoticz.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def getAog(device, user_id=None):
aog.customData['idx'] = device.get('idx')
aog.customData['domain'] = domain
aog.customData['protected'] = device.get('Protected')
aog.notificationSupportedByAgent = (True if domain in ['SmokeDetector', 'Doorbell', 'DoorLock'] else False)
aog.notificationSupportedByAgent = (True if domain in ['SmokeDetector', 'Doorbell', 'DoorLock', 'DoorLockInverted'] else False)

if domain == 'Scene':
aog.type = 'action.devices.types.SCENE'
Expand Down Expand Up @@ -220,7 +220,7 @@ def getAog(device, user_id=None):
aog.traits.append('action.devices.traits.OnOff')
if domain == 'Dimmer':
aog.traits.append('action.devices.traits.Brightness')
if domain == 'DoorLock':
if domain in ['DoorLock', 'DoorLockInverted']:
aog.type = 'action.devices.types.LOCK'
aog.traits.append('action.devices.traits.LockUnlock')

Expand Down
4 changes: 2 additions & 2 deletions modules/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ def getVersion():
if os.path.isfile(filename) and os.access(filename, os.R_OK):
with open(filename, mode='r') as f:
text = f.read()
text = text.split()
text = text.split("\n")

return text[0]
return text
else:
return None

Expand Down
5 changes: 4 additions & 1 deletion modules/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,10 @@ def uploader():
logger.warning("Uploadfile is not allowed")
flash("Uploadfile is not allowed, '.jpg','.png' files or 'smart-home-key.json' is allowed!")
else:
f.save(os.path.join(config.UPLOAD_DIRECTORY, secure_filename(f.filename)))
if f.filename == 'smart-home-key.json':
f.save(os.path.join(config.KEYFILE_DIRECTORY, secure_filename(f.filename)))
else:
f.save(os.path.join(config.UPLOAD_DIRECTORY, secure_filename(f.filename)))
logger.info("Upload success")

return redirect(url_for('settings'))
6 changes: 4 additions & 2 deletions static/js/smarthome.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ function refreshSwitches(updateSwitches) {
}
if (data == 'Unlocked'){
$('#icon_DoorLock_' + idx).html("lock_open").css('color','#008000')
$('#icon_DoorLockInverted_' + idx).html("lock_open").css('color','#008000')
}
if (data == 'Off'){
$('#icon_OnOff_' + idx).removeAttr('style')
Expand All @@ -122,6 +123,7 @@ function refreshSwitches(updateSwitches) {
}
if (data == 'Locked'){
$('#icon_DoorLock_' + idx).html("lock").css('color','#ED2939')
$('#icon_DoorLockInverted_' + idx).html("lock").css('color','#ED2939')
}
if (data == 'Normal'){
$('#icon_security_' + idx).removeAttr('style')
Expand Down Expand Up @@ -371,11 +373,11 @@ function checkVersion() {
url: "https://raw.githubusercontent.com/DewGew/DZGA-Flask/development/VERSION.md",
cache: false,
success: function( data ) {
dataFloat = data.split(",")[0];
dataFloat = data.split("\n")[0];
var compare = versionCompare(dataFloat, dzga_version);
if (compare == 1) {
$('#newver').html(" <i> (New version " + dataFloat + " is avalible.)</i>");
$('#newver_note').html('A new version ' + dataFloat + ' is avalible <a href="https://github.com/DewGew/DZGA-Flask" target="_blank">here</a>');
$('#newver_note').html('A new version ' + dataFloat + ' is avalible <a href="https://github.com/DewGew/DZGA-Flask" target="_blank">here</a>');
$('#badge').show();
$("#notes").html('You have 1 new notifications');
$("#shownotes" ).show();
Expand Down
6 changes: 3 additions & 3 deletions templates/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ <h5 class="card-title">Device log <span>| {{ v['name']['name'] }}</span></h5>
</div><!-- End Vertically centered Modal-->
</div>
</div>
{% elif v['customData']['domain'] == 'DoorLock' %}
{% elif v['customData']['domain'] in ('DoorLock', 'DoorLockInverted') %}
<div class="icon">
<div class="click" onclick="toogleSwitch({{ v['customData']['idx'] }}, '{{ v['customData']['protected'] }}')">
<i class="material-symbols-outlined" id="icon_{{ v['customData']['domain'] }}_{{ v['customData']['idx'] }}">lock</i>
Expand Down Expand Up @@ -673,7 +673,7 @@ <h5 id="title_other">Other devices <i class="bi bi-chevron-compact-down"></i></h
{% for k, v in devices.items() %}
{% if (v['customData']['domain'] not in (
'Group','Scene','Thermostat', 'Setpoint','Temp', 'TempHumidity', 'TempHumidityBaro','SmokeDetector', 'Security',
'VenetianBlindsEU', 'OnOff', 'Dimmer', 'VenetianBlindsUS', 'Doorbell', 'DoorLock', 'Selector', 'DoorContact', 'BlindsPercentage',
'VenetianBlindsEU', 'OnOff', 'Dimmer', 'VenetianBlindsUS', 'Doorbell', 'DoorLock', 'DoorLockInverted', 'Selector', 'DoorContact', 'BlindsPercentage',
'MotionSensor', 'PushOnButton', 'PushOffButton', 'ColorSwitch', 'Contact') and 'Hidden' not in v['customData']['domain'] ) %}
<div class="icon">
<i class="material-symbols-outlined" id="icon_{{ v['customData']['idx'] }}">unknown_2</i>
Expand Down Expand Up @@ -760,7 +760,7 @@ <h5 id="title_hidden" style="cursor: pointer;">Hidden devices <i class="bi bi-ch
updateSwitches_block.push("{{ v['customData']['idx'] }}")
$('#title_security').show()
{% elif (v['customData']['domain'] not in (
'SmokeDetector', 'Security', 'VenetianBlindsEU', 'OnOff', 'VenetianBlindsUS', 'Doorbell', 'DoorLock', 'DoorContact', 'BlindsPercentage',
'SmokeDetector', 'Security', 'VenetianBlindsEU', 'OnOff', 'VenetianBlindsUS', 'Doorbell', 'DoorLock', 'DoorLockInverted', 'DoorContact', 'BlindsPercentage',
'MotionSensor', 'PushOnButton', 'PushOffButton', 'Contact') and 'Hidden' not in v['customData']['domain']) %}
updateOthers_block.push("{{ v['customData']['idx'] }}")
$('#title_other').show()
Expand Down
2 changes: 1 addition & 1 deletion templates/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<script>
var csrf_token = "{{ _csrf_token }}";
var flask_server = "{{ request.url_root[:-1] }}".replace('http://', '//');
var dzga_version = "{{ version }}";
var dzga_version = "{{ version[0] }}";
getDzVersion()
checkVersion()
</script>
10 changes: 10 additions & 0 deletions templates/info.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ <h4><a href="https://smarthome-test-suite.withgoogle.com/devices" target="_blank
</p>

</div>
<div class="post-item clearfix">
<h4><a href="https://smarthome-test-suite.withgoogle.com/devices" target="_blank">Latest Updates </a></h4>
<p>
{% for x in version %}
{% if x != version[0] %}
{{ x }} </br>
{% endif %}
{% endfor %}
</p>
</div>
{% if user.googleassistant %}
<div class="post-item clearfix">
<h4><a href="https://smarthome-test-suite.withgoogle.com/devices" target="_blank">Home Graph Viewer </a></h4>
Expand Down

0 comments on commit 01053ab

Please sign in to comment.