Skip to content
Permalink
Browse files
Simple devices update
Simple devices: support of Air Conditioners added
  • Loading branch information
sergejey committed Jul 20, 2020
1 parent 2299f41 commit 140b194a5ba2130b3afab2e18bb59b68d660ce59
Show file tree
Hide file tree
Showing 15 changed files with 252 additions and 7 deletions.
@@ -118,6 +118,10 @@
font-weight:bold;
}

.device-icon.ac {
background-image: url(../cms/scenes/styles/common/i_condition_on_cool.png);
}

.device-icon.camera {
background-image: url(../cms/scenes/styles/common/i_camera_on.png);
}
@@ -142,6 +146,10 @@
background-color:yellow;
}

.device-icon.ac.on {
background-color:yellow;
}

.device-icon.motion.on {
background-color:yellow;
}
@@ -1312,6 +1312,19 @@
'DEVICES_ALL_BY_ROOM' => 'List all by rooms',
'DEVICES_LOAD_TIMEOUT' => 'Load status timeout',

'DEVICES_AC'=>'Air conditioner',
'DEVICES_AC_FAN_SPEED'=>'Fan speed',
'DEVICES_AC_FAN_SPEED_HIGH'=>'High',
'DEVICES_AC_FAN_SPEED_MEDIUM'=>'Medium',
'DEVICES_AC_FAN_SPEED_LOW'=>'Low',
'DEVICES_AC_FAN_SPEED_AUTO'=>'Auto',
'DEVICES_AC_THERMOSTAT'=>'Thermostat',
'DEVICES_AC_THERMOSTAT_FAN_ONLY'=>'Fan Only',
'DEVICES_AC_THERMOSTAT_HEAT'=>'Heat',
'DEVICES_AC_THERMOSTAT_COOL'=>'Cool',
'DEVICES_AC_THERMOSTAT_DRY'=>'Dry',
'DEVICES_AC_THERMOSTAT_AUTO'=>'Auto',

'DEVICES_DIMMER_MIN_WORK' => 'Min level (work)',
'DEVICES_DIMMER_MAX_WORK' => 'Max level (work)',
'DEVICES_DIMMER_SET_MAX' => 'Set maximum level when turning on',
@@ -1311,6 +1311,19 @@
'GROUPS' => 'Группы',
'APPLIES_TO' => 'Применительно к',

'DEVICES_AC'=>'Кондиционер',
'DEVICES_AC_FAN_SPEED'=>'Обдув',
'DEVICES_AC_FAN_SPEED_HIGH'=>'Сильный',
'DEVICES_AC_FAN_SPEED_MEDIUM'=>'Средний',
'DEVICES_AC_FAN_SPEED_LOW'=>'Малый',
'DEVICES_AC_FAN_SPEED_AUTO'=>'Авто',
'DEVICES_AC_THERMOSTAT'=>'Термостат',
'DEVICES_AC_THERMOSTAT_FAN_ONLY'=>'Только обдув',
'DEVICES_AC_THERMOSTAT_HEAT'=>'Подогрев',
'DEVICES_AC_THERMOSTAT_COOL'=>'Охлаждение',
'DEVICES_AC_THERMOSTAT_DRY'=>'Осушение',
'DEVICES_AC_THERMOSTAT_AUTO'=>'Авто',

'DEVICES_DIMMER_MIN_WORK' => 'Мин. уровень (рабочий)',
'DEVICES_DIMMER_MAX_WORK' => 'Макс. уровень (рабочий)',
'DEVICES_DIMMER_SET_MAX' => 'Устанавливать максимальную яркость при включении',
@@ -0,0 +1,17 @@
<?php

$fanSpeedModes = $this->getProperty('fanSpeedModes');
$tmp = explode(',',$fanSpeedModes);
$html='';
foreach($tmp as $mode) {
$html.='<option value="'.$mode.'">'.constant('LANG_DEVICES_AC_FAN_SPEED_'.strtoupper($mode));
}
$this->setProperty('fanSpeedModesHTML',$html);

$thermostatModes = $this->getProperty('thermostatModes');
$tmp = explode(',',$thermostatModes);
$html='';
foreach($tmp as $mode) {
$html.='<option value="'.$mode.'">'.constant('LANG_DEVICES_AC_THERMOSTAT_'.strtoupper($mode));
}
$this->setProperty('thermostatModesHTML',$html);
@@ -0,0 +1,8 @@
<?php

if (!isset($params['value'])) return;
$value = $params['value'];

$targetTitle = 'fanSpeed';

$this->setProperty($targetTitle,$value);
@@ -0,0 +1,8 @@
<?php

if (!isset($params['value'])) return;
$value = $params['value'];

$targetTitle = 'currentTargetValue';

$this->setProperty($targetTitle,$value);
@@ -0,0 +1,8 @@
<?php

if (!isset($params['value'])) return;
$value = $params['value'];

$targetTitle = 'thermostat';

$this->setProperty($targetTitle,$value);
@@ -0,0 +1,13 @@
<?php
$status = $this->getProperty('status');

if (isset($params['value'])) {
$threshold = $params['value'];
} else {
$threshold = -0.5;
}

$targetTitle='currentTargetValue';
$targetTemperature = $this->getProperty($targetTitle);
$targetTemperature+=$threshold;
$this->setProperty($targetTitle,$targetTemperature);
@@ -0,0 +1,13 @@
<?php

$status = $this->getProperty('status');
if (isset($params['value'])) {
$threshold = $params['value'];
} else {
$threshold = +0.5;
}

$targetTitle='currentTargetValue';
$targetTemperature = $this->getProperty($targetTitle);
$targetTemperature+=$threshold;
$this->setProperty($targetTitle,$targetTemperature);
@@ -141,7 +141,11 @@
if ($this->mode == 'update') {
global ${$k . '_value'};
if (isset(${$k . '_value'})) {
setGlobal($rec['LINKED_OBJECT'] . '.' . $k, trim(${$k . '_value'}));
if (is_array(${$k . '_value'})) {
setGlobal($rec['LINKED_OBJECT'] . '.' . $k, implode(',',${$k . '_value'}));
} else {
setGlobal($rec['LINKED_OBJECT'] . '.' . $k, trim(${$k . '_value'}));
}
}
$out['OK'] = 1;
if ($v['ONCHANGE'] != '') {
@@ -152,7 +156,8 @@
if (isset($v['_CONFIG_HELP'])) $v['CONFIG_HELP'] = $v['_CONFIG_HELP'];
$v['CONFIG_TYPE'] = $v['_CONFIG_TYPE'];
$v['VALUE'] = getGlobal($rec['LINKED_OBJECT'] . '.' . $k);
if ($v['CONFIG_TYPE'] == 'select') {
if ($v['CONFIG_TYPE'] == 'select' || $v['CONFIG_TYPE'] == 'multi_select') {
$selected_options = explode(',',gg($rec['LINKED_OBJECT'] . '.' . $k));
$tmp = explode(',', $v['_CONFIG_OPTIONS']);
$total = count($tmp);
for ($i = 0; $i < $total; $i++) {
@@ -163,7 +168,9 @@
} else {
$title = $value;
}
$v['OPTIONS'][] = array('VALUE' => $value, 'TITLE' => $title);
$option = array('VALUE' => $value, 'TITLE' => $title);
if (in_array($value,$selected_options)) $option['SELECTED']=1;
$v['OPTIONS'][] = $option;
}
} elseif ($v['CONFIG_TYPE'] == 'style_image') {
include_once(DIR_MODULES . 'scenes/scenes.class.php');
@@ -428,6 +435,14 @@
setGlobal($object_rec['TITLE'] . '.linkedRoom', $location_title);
}

if ($added && is_array($type_details['PROPERTIES'])) {
foreach($type_details['PROPERTIES'] as $property=>$details) {
if (IsSet($details['_CONFIG_DEFAULT'])) {
setGlobal($object_rec['TITLE'] . '.'.$property, $details['_CONFIG_DEFAULT']);
}
}
}

if ($added && $rec['TYPE'] == 'sensor_temp') {
setGlobal($object_rec['TITLE'] . '.minValue', 16);
setGlobal($object_rec['TITLE'] . '.maxValue', 25);
@@ -98,9 +98,9 @@
'PROPERTIES'=>array(
'relay_status'=>array('DESCRIPTION'=>LANG_DEVICES_THERMOSTAT_RELAY_STATUS,'KEEP_HISTORY'=>365,'DATA_KEY'=>1),
'value'=>array('DESCRIPTION'=>LANG_DEVICES_THERMOSTAT_CURRENT_TEMP,'ONCHANGE'=>'valueUpdated','KEEP_HISTORY'=>365,'DATA_KEY'=>1),
'currentTargetValue'=>array('DESCRIPTION'=>LANG_DEVICES_THERMOSTAT_CURRENT_TARGET_TEMP,'DATA_KEY'=>1),
'normalTargetValue'=>array('DESCRIPTION'=>LANG_DEVICES_THERMOSTAT_NORMAL_TEMP,'_CONFIG_TYPE'=>'text','ONCHANGE'=>'valueUpdated','_CONFIG_HELP'=>'SdThermostat'),
'ecoTargetValue'=>array('DESCRIPTION'=>LANG_DEVICES_THERMOSTAT_ECO_TEMP,'_CONFIG_TYPE'=>'text','ONCHANGE'=>'valueUpdated','_CONFIG_HELP'=>'SdThermostat'),
'currentTargetValue'=>array('DESCRIPTION'=>LANG_DEVICES_THERMOSTAT_CURRENT_TARGET_TEMP,'DATA_KEY'=>1,'_CONFIG_DEFAULT'=>22),
'normalTargetValue'=>array('DESCRIPTION'=>LANG_DEVICES_THERMOSTAT_NORMAL_TEMP,'_CONFIG_TYPE'=>'text','ONCHANGE'=>'valueUpdated','_CONFIG_HELP'=>'SdThermostat','_CONFIG_DEFAULT'=>22),
'ecoTargetValue'=>array('DESCRIPTION'=>LANG_DEVICES_THERMOSTAT_ECO_TEMP,'_CONFIG_TYPE'=>'text','ONCHANGE'=>'valueUpdated','_CONFIG_HELP'=>'SdThermostat','_CONFIG_DEFAULT'=>18),
'threshold'=>array('DESCRIPTION'=>LANG_DEVICES_THERMOSTAT_THRESHOLD,'_CONFIG_TYPE'=>'text','ONCHANGE'=>'valueUpdated','_CONFIG_HELP'=>'SdThermostat'),
'ncno'=>array('DESCRIPTION'=>LANG_DEVICES_NCNO,'_CONFIG_TYPE'=>'select','_CONFIG_OPTIONS'=>'nc=Normal Close,no=Normal Open','_CONFIG_HELP'=>'SdThermostat'),
'disabled' =>array('DESCRIPTION'=>'Disabled'),
@@ -118,6 +118,37 @@
'turnOff'=>array('DESCRIPTION'=>LANG_DEVICES_THERMOSTAT_MODE.': '.LANG_DEVICES_THERMOSTAT_MODE_ECO,'_CONFIG_SHOW'=>1),
)
),
'ac' => array(
'TITLE'=>LANG_DEVICES_AC,
'PARENT_CLASS'=>'SControllers',
'CLASS'=>'SAirConditioners',
'PROPERTIES'=>array(
'value'=>array('DESCRIPTION'=>LANG_DEVICES_THERMOSTAT_CURRENT_TEMP,'ONCHANGE'=>'valueUpdated','KEEP_HISTORY'=>365,'DATA_KEY'=>1),
'currentTargetValue'=>array('DESCRIPTION'=>LANG_DEVICES_THERMOSTAT_CURRENT_TARGET_TEMP,'DATA_KEY'=>1,'_CONFIG_DEFAULT'=>22),
'fanSpeed'=>array('DESCRIPTION'=>'Fan Speed','_CONFIG_DEFAULT'=>'auto'),
'fanSpeedModes'=>array('DESCRIPTION'=>LANG_DEVICES_AC_FAN_SPEED,
'_CONFIG_TYPE'=>'multi_select',
'_CONFIG_OPTIONS'=>'high='.LANG_DEVICES_AC_FAN_SPEED_HIGH.',medium='.LANG_DEVICES_AC_FAN_SPEED_MEDIUM.',low='.LANG_DEVICES_AC_FAN_SPEED_LOW.',auto='.LANG_DEVICES_AC_FAN_SPEED_AUTO,
'_CONFIG_DEFAULT'=>'high,medium,low,auto','ONCHANGE'=>'configUpdated','ONCHANGE'=>'fanSpeedUpdated'),
'fanSpeedModesHTML'=>array('DESCRIPTION'=>'FanSpeedModes HTML'),
'thermostat'=>array('DESCRIPTION'=>'Thermostat','_CONFIG_DEFAULT'=>'auto','ONCHANGE'=>'thermostatUpdated'),
'thermostatModes'=>array('DESCRIPTION'=>LANG_DEVICES_AC_THERMOSTAT,
'_CONFIG_TYPE'=>'multi_select',
'_CONFIG_OPTIONS'=>'fan_only='.LANG_DEVICES_AC_THERMOSTAT_FAN_ONLY.',heat='.LANG_DEVICES_AC_THERMOSTAT_HEAT.',cool='.LANG_DEVICES_AC_THERMOSTAT_COOL.',dry='.LANG_DEVICES_AC_THERMOSTAT_DRY.',auto='.LANG_DEVICES_AC_THERMOSTAT_AUTO,
'_CONFIG_DEFAULT'=>'fan_only,heat,cool,dry,auto','ONCHANGE'=>'configUpdated'),
'thermostatModesHTML'=>array('DESCRIPTION'=>'ThermostatModes HTML'),
),
'METHODS'=>array(
'setTargetTemperature'=>array('DESCRIPTION'=>'Set target temperature'),
'setThermostatMode'=>array('DESCRIPTION'=>'Set thermostat mode'),
'setFanSpeedMode'=>array('DESCRIPTION'=>'Set fan speed mode'),
'configUpdated'=>array('DESCRIPTION'=>'Config updated'),
'fanSpeedUpdated'=>array('DESCRIPTION'=>'Fan Speed updated'),
'thermostatUpdated'=>array('DESCRIPTION'=>'Thermostat updated'),
'tempUp'=>array('DESCRIPTION'=>'Increase target temperature'),
'tempDown'=>array('DESCRIPTION'=>'Descrease target temperature'),
)
),
'dimmer'=>array(
'TITLE'=>LANG_DEVICES_DIMMER,
'PARENT_CLASS'=>'SControllers',
@@ -952,6 +952,8 @@ function setProperty($property, $value, $no_linked = 0, $source = '')
$p_lower == 'volume' ||
$p_lower == 'channel' ||
$p_lower == 'mode' ||
$p_lower == 'thermostatmode' ||
$p_lower == 'fanspeedmode' ||
$p_lower == 'currenttargetvalue') //
) {
addToOperationsQueue('connect_device_data', $this->object_title . '.' . $property, $value, true);
@@ -0,0 +1,84 @@
<div class="device-widget ac %.alive|"offline;online"%" id='deviceid_%.object_title%'>
<div class="device-icon ac %.status|"off;on"% icon%.object_id%_thermostat"></div>
<div class="device-header">%.object_description%</div>
<div class="device-details"><#LANG_DEVICES_THERMOSTAT_CURRENT_TARGET_TEMP#>:<br/>
<a href="#" class="btn btn-default btn-sm" onClick='$(".icon%.object_id%_thermostat").addClass("pressed");setTimeout("$(\".icon%.object_id%_thermostat\").removeClass(\"pressed\");",300);
callMethod("%.object_title%.tempDown");
$.get("<#ROOTHTML#>ajax/devices.html?op=clicked&object="+encodeURIComponent("%.object_title%"));
return false;'>-</a>
%.currentTargetValue%
<a href="#" class="btn btn-default btn-sm" onClick='$(".icon%.object_id%_thermostat").addClass("pressed");setTimeout("$(\".icon%.object_id%_thermostat\").removeClass(\"pressed\");",300);
callMethod("%.object_title%.tempUp");
$.get("<#ROOTHTML#>ajax/devices.html?op=clicked&object="+encodeURIComponent("%.object_title%"));
return false;'>+</a>

<a href="#" class="btn btn-default btn-sm" onClick='$(".icon%.object_id%_thermostat").addClass("pressed");setTimeout("$(\".icon%.object_id%_thermostat\").removeClass(\"pressed\");",300);
callMethod("%.object_title%.turnOff");
$.get("<#ROOTHTML#>ajax/devices.html?op=clicked&object="+encodeURIComponent("%.object_title%"));
return false;'><#LANG_OFF#></a>
<a href="#" class="btn btn-default btn-sm" onClick='$(".icon%.object_id%_thermostat").addClass("pressed");setTimeout("$(\".icon%.object_id%_thermostat\").removeClass(\"pressed\");",300);
callMethod("%.object_title%.turnOn");
$.get("<#ROOTHTML#>ajax/devices.html?op=clicked&object="+encodeURIComponent("%.object_title%"));
return false;'><#LANG_ON#></a>

</div>
<div class="device-details"><#LANG_DEVICES_THERMOSTAT_CURRENT_TEMP#>: %.value% [<a href="#" onclick="var url=('<#ROOTHTML#>pChart/?p[]=%.object_title%'+'.value&p[]=%.object_title%'+'.relay_status&op=log&subop=24h&minimal=1');parent.$.fancybox.open({ src: url, type: 'iframe',iframe:{preload:false} });return false;"><#LANG_HISTORY#></a>]</div>
<div class="device-details">
<#LANG_DEVICES_AC_FAN_SPEED#>:
<span id="acFanSpeed%.object_id%_content" style="display:none">%.fanSpeed%</span>
<select id="acFanSpeed%.object_id%" onchange="acFanSpeedSet%.object_id%(this.value);" style="color:black">
<option value=""></option>
%.fanSpeedModesHTML%
</select>
<#LANG_DEVICES_AC_THERMOSTAT#>:

<span id="acThermostat%.object_id%_content" style="display:none">%.thermostat%</span>
<select id="acThermostat%.object_id%" onchange="acThermostatSet%.object_id%(this.value);" style="color:black">
<option value=""></option>
%.thermostatModesHTML%
</select>
</div>
</div>
<script type="text/javascript">
function acStatusSet%.object_id%(value) {
$(".icon%.object_id%_thermostat").addClass("pressed");setTimeout("$(\".icon%.object_id%_thermostat\").removeClass(\"pressed\");",300);
if (value==1) {
callMethod("%.object_title%.turnOn");
} else {
callMethod("%.object_title%.turnOff");
}
$.get("<#ROOTHTML#>ajax/devices.html?op=clicked&object="+encodeURIComponent("%.object_title%"));
}
function acFanSpeedSet%.object_id%(value) {
$(".icon%.object_id%_thermostat").addClass("pressed");setTimeout("$(\".icon%.object_id%_thermostat\").removeClass(\"pressed\");",300);
setGlobal("%.object_title%.fanSpeed",value);
$.get("<#ROOTHTML#>ajax/devices.html?op=clicked&object="+encodeURIComponent("%.object_title%"));
}
function acThermostatSet%.object_id%(value) {
$(".icon%.object_id%_thermostat").addClass("pressed");setTimeout("$(\".icon%.object_id%_thermostat\").removeClass(\"pressed\");",300);
setGlobal("%.object_title%.thermostat",value);
$.get("<#ROOTHTML#>ajax/devices.html?op=clicked&object="+encodeURIComponent("%.object_title%"));
}
/*
var oldFanSpeed%.object_id%='%.fanSpeed%';
var oldThermostat%.object_id%='%.thermostat%';
$('#acFanSpeed%.object_id%').val('%.fanSpeed%');
$('#acThermostat%.object_id%').val('%.thermostat%');
*/


function acCheckCurrentValues%.object_id%() {
var fanSpeed = $('#acFanSpeed%.object_id%_content').html();
if ($('#acFanSpeed%.object_id%').val()!=fanSpeed) {
$('#acFanSpeed%.object_id%').val(fanSpeed);
}
var thermostat = $('#acThermostat%.object_id%_content').html();
if ($('#acThermostat%.object_id%').val()!=thermostat) {
$('#acThermostat%.object_id%').val(thermostat);
}
}
//acCheckCurrentValues%.object_id%();
var acCheckInterval = setInterval(acCheckCurrentValues%.object_id%,1000);


</script>
@@ -58,6 +58,13 @@
</select>
[#endif#]

[#if CONFIG_TYPE="multi_select"#]
[#begin OPTIONS#]
<input type="checkbox" name="<#PROPERTIES.NAME#>_value[]" value="[#VALUE#]"[#if SELECTED#] checked[#endif#]> [#TITLE#]<br/>
[#end OPTIONS#]
</select>
[#endif#]

[#if CONFIG_TYPE="style_image"#]
<div id="style_image_set_[#NAME#]">
[#if VALUE!=""#]
@@ -94,6 +94,11 @@
<div style="display:none">
<audio id="click_sound" src="{$smarty.const.SETTINGS_SCENES_CLICKSOUND}" controls preload="auto" autobuffer>
</audio>
<script type="text/javascript">
var thissound=document.getElementById('click_sound');
thissound.play();
setTimeout(thissound.pause.bind(thissound), 10);
</script>
</div>
{/if}
{if $TOTAL_SCENES!="1"}
@@ -193,7 +198,7 @@ $.fn.customContextMenu = function(callBack){
var window_url;
{if $smarty.const.SETTINGS_SCENES_CLICKSOUND!=""}
setTimeout("EvalSound('click_sound')",100);
setTimeout("EvalSound('click_sound')",10);
{/if}
$('#state_'+id).animate({ opacity: .5 }, 100).animate({ opacity: 1 }, 100);

0 comments on commit 140b194

Please sign in to comment.