2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-02-25 09:55:38 +00:00

HMCCU: fixed thermostat commands

git-svn-id: https://svn.fhem.de/fhem/trunk@28611 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
zap 2024-03-07 17:19:22 +00:00
parent 9297d60892
commit 6420af9598
5 changed files with 82 additions and 45 deletions

View File

@ -57,7 +57,7 @@ my %HMCCU_CUST_CHN_DEFAULTS;
my %HMCCU_CUST_DEV_DEFAULTS;
# HMCCU version
my $HMCCU_VERSION = '5.0 2024-02';
my $HMCCU_VERSION = '5.0 2024-03';
# Timeout for CCU requests (seconds)
my $HMCCU_TIMEOUT_REQUEST = 4;
@ -6635,9 +6635,14 @@ sub HMCCU_UpdateRoleCommands ($$)
my $cmdChn = $channel;
my $cmdType = 'set';
if ($cmd =~ /^(set|get) (.+)$/) {
my $forceRPC = 0;
if ($cmd =~ /^(set|get|rpcset|rpcget) (.+)$/) {
$cmdType = $1;
$cmd = $2;
if ($cmdType =~ /^rpc/) {
$forceRPC = 1;
$cmdType =~ s/rpc//;
}
}
next URCCMD if (exists($clHash->{hmccu}{roleCmds}{$cmdType}{$cmd}) && defined($clHash->{hmccu}{roleCmds}{$cmdType}{$cmd}{channel}) &&
$cc ne '' && "$clHash->{hmccu}{roleCmds}{$cmdType}{$cmd}{channel}" eq "$cc");
@ -6656,6 +6661,7 @@ sub HMCCU_UpdateRoleCommands ($$)
$clHash->{hmccu}{roleCmds}{$cmdType}{$cmd}{syntax} = $cmdSyntax;
$clHash->{hmccu}{roleCmds}{$cmdType}{$cmd}{role} = $role;
$clHash->{hmccu}{roleCmds}{$cmdType}{$cmd}{rpc} = $forceRPC;
my $cnt = 0;
my $cmdDef = $cmd;
@ -6676,9 +6682,15 @@ sub HMCCU_UpdateRoleCommands ($$)
my ($ps, $dptList, $par, $fnc) = @subCmdList;
my $psName = $ps eq 'I' ? 'VALUES' : $pset{$ps};
if (!defined($psName)) {
HMCCU_Log ($clHash, 4, "HMCCUConf: Invalid or undefined parameter set in role $role, command $cmd $subCmd");
HMCCU_Log ($clHash, 2, "HMCCUConf: Invalid or undefined parameter set in role $role, command $cmd $subCmd");
next URCSUB;
}
$clHash->{hmccu}{roleCmds}{$cmdType}{$cmd}{ps} //= $psName;
if ($forceRPC && $psName ne $clHash->{hmccu}{roleCmds}{$cmdType}{$cmd}{ps}) {
HMCCU_Log ($clHash, 2, "HMCCUConf: RPC mode doesn't allow mixed paramsets in one command");
next URCSUB;
}
$cmdChn = 'd' if ($ps eq 'D');
# Allow different datapoint/config parameter names for same command, if name depends on firmware revision of device type
@ -6701,13 +6713,13 @@ sub HMCCU_UpdateRoleCommands ($$)
}
}
if (!$dptValid) {
HMCCU_Log ($clHash, 4, "HMCCUConf: Invalid parameter $addr:$cmdChn $psName $dpt $parAccess in role $role, command $cmd $subCmd");
HMCCU_Log ($clHash, 2, "HMCCUConf: Invalid parameter $addr:$cmdChn $psName $dpt $parAccess in role $role, command $cmd $subCmd");
next URCSUB;
}
my $paramDef = HMCCU_GetParamDef ($ioHash, "$addr:$cmdChn", $psName, $dpt);
if (!defined($paramDef)) {
HMCCU_Log ($ioHash, 4, "HMCCUConf: Can't get definition of datapoint $addr:$cmdChn.$dpt. Ignoring command $cmd in role $role for device $clHash->{NAME}");
HMCCU_Log ($ioHash, 2, "HMCCUConf: Can't get definition of datapoint $addr:$cmdChn.$dpt. Ignoring command $cmd in role $role for device $clHash->{NAME}");
next URCCMD;
}
$clHash->{hmccu}{roleCmds}{$cmdType}{$cmd}{subcmd}{$scn}{scn} = sprintf("%03d", $subCmdNo);
@ -6735,6 +6747,9 @@ sub HMCCU_UpdateRoleCommands ($$)
my ($cNam, $cVal) = split (':', $e);
if (defined($cVal)) {
push @cNames, $cNam;
if (!HMCCU_IsFltNum($cVal)) {
HMCCU_Log ($clHash, 2, "cVal $cVal is not numeric. Enum = $el, type = $clHash->{ccutype}, dpt=$dpt, role=$role");
}
$min = $cVal if (!defined($min) || $cVal<$min);
$max = $cVal if (!defined($max) || $cVal>$max);
$clHash->{hmccu}{roleCmds}{$cmdType}{$cmd}{subcmd}{$scn}{look}{$cNam} = $cVal;
@ -6936,6 +6951,8 @@ sub HMCCU_ExecuteRoleCommand ($@)
my %cmdFnc;
my ($devAddr, undef) = HMCCU_SplitChnAddr ($clHash->{ccuaddr});
my $usage = $clHash->{hmccu}{roleCmds}{$mode}{$command}{usage};
my $forceRPC = $clHash->{hmccu}{roleCmds}{$mode}{$command}{rpc};
my $psName = $clHash->{hmccu}{roleCmds}{$mode}{$command}{ps} // 'MASTER';
my $channel = $clHash->{hmccu}{roleCmds}{$mode}{$command}{channel} // '?';
if ("$channel" eq '?') {
@ -7003,7 +7020,7 @@ sub HMCCU_ExecuteRoleCommand ($@)
elsif ($cmd->{partype} == 2) {
# Normal value
$value = shift @$a // $cmd->{args};
return HMCCU_SetError ($clHash, "Missing parameter $cmd->{parname}. Usage: $mode $name $usage")
return HMCCU_SetError ($clHash, "Missing parameter $cmd->{parname}.\nUsage: $mode $name $usage")
if ($value eq '');
return HMCCU_SetError ($clHash, "Usage: $mode $name $usage")
if ($value eq '?');
@ -7049,22 +7066,22 @@ sub HMCCU_ExecuteRoleCommand ($@)
# HMCCU_Trace ($clHash, 2, "scMin=$scMin, scMax=$scMax, scVal=$value");
# }
if ($cmd->{ps} eq 'VALUES') {
if ($cmd->{type} eq 'BOOL' && HMCCU_IsIntNum($value)) {
$value = $value > 0 ? 'true' : 'false';
}
if ($combDpt eq '') {
if ($combDpt eq '') {
if ($cmd->{ps} eq 'VALUES' && !$forceRPC) {
if ($cmd->{type} eq 'BOOL' && HMCCU_IsIntNum($value)) {
$value = $value > 0 ? 'true' : 'false';
}
$dpval{"$cmd->{scn}.$clHash->{ccuif}.$chnAddr.$cmd->{dpt}"} = $value;
}
elsif ($cmd->{ps} eq 'INTERNAL') {
$inval{$cmd->{parname}} = $value;
}
else {
push @combArgs, $value;
$cfval{$cmd->{dpt}} = $value;
}
}
elsif ($cmd->{ps} eq 'INTERNAL') {
$inval{$cmd->{parname}} = $value;
}
else {
$cfval{$cmd->{dpt}} = $value;
push @combArgs, $value;
}
push @par, $value if (defined($value));
@ -7073,7 +7090,12 @@ sub HMCCU_ExecuteRoleCommand ($@)
}
if (scalar(@combArgs) > 0) {
$dpval{"000.$clHash->{ccuif}.$chnAddr.$combDpt"} = sprintf($combStr, @combArgs);
if ($forceRPC) {
$cfval{$combDpt} = sprintf($combStr, @combArgs);
}
else {
$dpval{"000.$clHash->{ccuif}.$chnAddr.$combDpt"} = sprintf($combStr, @combArgs);
}
}
my $ndpval = scalar(keys %dpval);
@ -7099,7 +7121,7 @@ sub HMCCU_ExecuteRoleCommand ($@)
if ($ncfval > 0) {
# Config commands
foreach my $pv (keys %cfval) { HMCCU_Trace ($clHash, 2, "Parameter $pv=$cfval{$pv}"); }
($rc, undef) = HMCCU_SetMultipleParameters ($clHash, $chnAddr, \%cfval, 'MASTER');
($rc, undef) = HMCCU_SetMultipleParameters ($clHash, $chnAddr, \%cfval, $psName);
return HMCCU_SetError ($clHash, HMCCU_Min(0, $rc));
}
}

View File

@ -30,7 +30,7 @@ sub HMCCUCHN_Set ($@);
sub HMCCUCHN_Get ($@);
sub HMCCUCHN_Attr ($@);
my $HMCCUCHN_VERSION = '5.0 2024-02';
my $HMCCUCHN_VERSION = '5.0 2024-03';
######################################################################
# Initialize module
@ -523,6 +523,12 @@ sub HMCCUCHN_Get ($@)
<li><b>set &lt;name&gt; armState {DISARMED|EXTSENS_ARMED|ALLSENS_ARMED|ALARM_BLOCKED}</b><br/>
[alarm siren] Set arm state.
</li><br/>
<li><b>set &lt;name&gt; auto</b><br/>
[thermostat] Turn auto mode on.
</li><br/>
<li><b>set &lt;name&gt; boost {on|off}</b><br/>
[thermostat] Turn boost mode on or off
</li><br/>
<li><b>set &lt;name&gt; calibrate {START|STOP}</b><br/>
[blind] Run calibration.
</li><br/>
@ -593,14 +599,17 @@ sub HMCCUCHN_Get ($@)
[dimmer, blind] Decrement value of datapoint LEVEL. This command is only available
if channel contains a datapoint LEVEL. Default for <i>value</i> is 20.
</li><br/>
<li><b>set &lt;name&gt; manu [&lt;temperature&gt;]</b><br/>
[thermostat] Set manual mode. Default temperature is 20.
</li><br/>
<li><b>set &lt;name&gt; off</b><br/>
Turn device off.
[switch,thermostat,dimmer] Turn device off.
</li><br/>
<li><b>set &lt;name&gt; oldLevel</b><br/>
[dimmer, blind, jalousie, shutter] Set level to previous value.
</li><br/>
<li><b>set &lt;name&gt; on</b><br/>
Turn device on.
[switch,thermostat,dimmer] Turn device on.
</li><br/>
<li><b>set &lt;name&gt; on-for-timer &lt;ontime&gt;</b><br/>
[switch] Switch device on for specified number of seconds. This command is only available if
@ -617,6 +626,9 @@ sub HMCCUCHN_Get ($@)
<li><b>set &lt;name&gt; open</b><br/>
[blind,door] Set level of a shutter or blind to 100%.
</li><br/>
<li><b>set &lt;name&gt; party &lt;temperature&gt; &lt;start-time&gt; &lt;end-time&gt;</b><br/>
[thermostat] Turn party mode on. Timestamps must be in format "YYYY_MM_DD HH:MM".
</li><br/>
<li><b>set &lt;name&gt; pct &lt;value&gt; [&lt;ontime&gt; [&lt;ramptime&gt;]]</b><br/>
[dimmer,blind] Set datapoint LEVEL of a channel to the specified <i>value</i>. Optionally a <i>ontime</i>
and a <i>ramptime</i> (both in seconds) can be specified. This command is only available
@ -645,14 +657,7 @@ sub HMCCUCHN_Get ($@)
channel contains a datapoint STOP.
</li><br/>
<li><b>set &lt;name&gt; toggle</b><br/>
Toggle state datapoint between values defined by attribute 'statevals' or by channel role. This command is
only available if state values can be detected or are defined by using attribute
'statevals'. Toggling supports more than two state values.<br/><br/>
Example: Toggle blind actor between states 'open', 'half' and 'close'<br/>
<code>
attr myswitch statevals open:100,half:50,close:0<br/>
set myswitch toggle
</code>
[switch,dimmer,blind] Toggle state between values on/off or open/close.
</li><br/>
<li><b>set &lt;name&gt; up [&lt;value&gt;]</b><br/>
[blind,dimmer] Increment value of datapoint LEVEL. This command is only available

View File

@ -31,7 +31,7 @@ sub HMCCUDEV_Set ($@);
sub HMCCUDEV_Get ($@);
sub HMCCUDEV_Attr ($@);
my $HMCCUDEV_VERSION = '5.0 2024-02';
my $HMCCUDEV_VERSION = '5.0 2024-03';
######################################################################
# Initialize module

View File

@ -36,7 +36,7 @@ use SetExtensions;
######################################################################
# HMCCURPC version
my $HMCCURPCPROC_VERSION = '5.0 2024-02';
my $HMCCURPCPROC_VERSION = '5.0 2024-03';
# Maximum number of events processed per call of Read()
my $HMCCURPCPROC_MAX_EVENTS = 100;

View File

@ -264,6 +264,7 @@ $HMCCU_CONFIG_VERSION = '5.0';
'^(C#\.)?ACTUAL_TEMPERATURE$:+measured-temp;'.
'^(C#\.)?ACTUAL_HUMIDITY$:+humidity;'.
'^(C#\.)?SET_TEMPERATURE$:+desired-temp',
'^(C#\.)?BOOST_MODE$:+boost',
'CLIMATE_TRANSCEIVER' =>
'^(C#\.)?ACTUAL_TEMPERATURE$:+measured-temp;'.
'^(C#\.)?ACTUAL_HUMIDITY$:+humidity',
@ -284,6 +285,7 @@ $HMCCU_CONFIG_VERSION = '5.0';
'^(C#\.)?HUMIDITY$:+humidity;'.
'^(C#\.)?ACTUAL_HUMIDITY$:+humidity;'.
'^(C#\.)?SET_POINT_TEMPERATURE$:+desired-temp',
'^(C#\.)?BOOST_MODE$:+boost',
'JALOUSIE' =>
'^(C#\.)?LEVEL$:+pct,+level;(C#\.)?LEVEL_SLATS$:+pctSlats',
'KEY' =>
@ -308,6 +310,7 @@ $HMCCU_CONFIG_VERSION = '5.0';
'^(C#\.)?ACTUAL_TEMPERATURE$:+measured-temp;'.
'^(C#\.)?ACTUAL_HUMIDITY$:+humidity;'.
'^(C#\.)?SET_TEMPERATURE$:+desired-temp',
'^(C#\.)?BOOST_MODE$:+boost',
'VIRTUAL_KEY' =>
'^(C#\.)?PRESS_(SHORT|LONG)$:+pressed',
'WEATHER' =>
@ -350,12 +353,12 @@ $HMCCU_CONFIG_VERSION = '5.0';
# Command with one parameter: Paramset:Datapoints:?Parameter
# Optional parameter with default: Paramset:Datapoints:?Parameter=Default-Value
# List of values: Paramset:Datapoints:#Parameter[=Value[,...]]
# Internal value (paramset "I"): Paramset:Datapoints:*Parameter=Default-Value
# Internal value (paramset "I"): I:Datapoints:*Parameter=Default-Value
# Paramset:
# V=VALUES, M=MASTER (channel), D=MASTER (device), I=INTERNAL, S=VALUE_STRING
# Datapoints:
# List of datapoint or config parameter names separated by ','. Multiple names can
# be specified to support multiple firmware revesions with different names.
# be specified to support multiple firmware revisions with different names.
# Parameter characters:
# ? = any value is accepted
# # = If datapoint is of type ENUM, values are taken from parameter set description.
@ -425,7 +428,7 @@ $HMCCU_CONFIG_VERSION = '5.0';
'on' => 'V:MANU_MODE:30.5',
'off' => 'V:MANU_MODE:4.5',
'auto' => 'V:AUTO_MODE:1',
'boost' => 'V:BOOST_MODE:1',
'boost' => 'V:BOOST_MODE:#boost=0,1',
'week-program:VirtualDevices' => 'D:WEEK_PROGRAM_POINTER:#program',
'get week-program:VirtualDevices' => 'D:WEEK_PROGRAM_POINTER:#program:HMCCU_DisplayWeekProgram'
},
@ -469,11 +472,15 @@ $HMCCU_CONFIG_VERSION = '5.0';
'ventilate' => 'V:DOOR_COMMAND:4'
},
'HEATING_CLIMATECONTROL_TRANSCEIVER' => {
# CONTROL_MODE (write): 0=Auto, 1=Manual, 2=Holiday/Party 3=NoFunction
# SET_POINT_MODE (read): 0=Auto, 1=Manual, 2=Holiday/Party
# Party: CONTROL_MODE=2, PARTY_TIME_START=Ts, PARTY_TIME_END=Ts, Ts="YYYY_MM_DD HH:MM"
'desired-temp' => 'V:SET_POINT_TEMPERATURE:?temperature',
'auto' => 'V:CONTROL_MODE:0',
'manu' => 'V:CONTROL_MODE:1',
'holiday' => 'V:CONTROL_MODE:2',
'boost' => 'V:BOOST_MODE:1',
'manu' => 'V:CONTROL_MODE:1 V:SET_POINT_TEMPERATURE:?temperature=20',
'rpcset holiday' => 'V:SET_POINT_MODE:2 V:SET_POINT_TEMPERATURE:?temperature V:PARTY_TIME_START:?timeStart V:PARTY_TIME_END:?timeEnd',
'rpcset party' => 'V:SET_POINT_MODE:2 V:SET_POINT_TEMPERATURE:?temperature V:PARTY_TIME_START:?timeStart V:PARTY_TIME_END:?timeEnd',
'boost' => 'V:BOOST_MODE:#boost=0,1',
'on' => 'V:CONTROL_MODE:1 V:SET_POINT_TEMPERATURE:30.5',
'off' => 'V:CONTROL_MODE:1 V:SET_POINT_TEMPERATURE:4.5'
},
@ -573,7 +580,7 @@ $HMCCU_CONFIG_VERSION = '5.0';
'on' => 'V:MANU_MODE:30.5',
'off' => 'V:MANU_MODE:4.5',
'auto' => 'V:AUTO_MODE:1',
'boost' => 'V:BOOST_MODE:1',
'boost' => 'V:BOOST_MODE:#boost=0,1',
'week-program' => 'D:WEEK_PROGRAM_POINTER:#program',
'get week-program' => 'D:WEEK_PROGRAM_POINTER:#program:HMCCU_DisplayWeekProgram'
},
@ -705,7 +712,7 @@ $HMCCU_CONFIG_VERSION = '5.0';
},
'THERMALCONTROL_TRANSMIT' => {
'substexcl' => 'desired-temp',
'cmdIcon' => 'auto:sani_heating_automatic manu:sani_heating_manual boost:sani_heating_boost on:general_an off:general_aus',
'cmdIcon' => 'auto:sani_heating_automatic manu:sani_heating_manual on:general_an off:general_aus',
'webCmd' => 'desired-temp:auto:manu:boost:on:off',
'widgetOverride' => 'desired-temp:slider,4.5,0.5,30.5,1'
},
@ -717,13 +724,13 @@ $HMCCU_CONFIG_VERSION = '5.0';
},
'CLIMATECONTROL_RT_TRANSCEIVER' => {
'substexcl' => 'desired-temp',
'cmdIcon' => 'auto:sani_heating_automatic manu:sani_heating_manual boost:sani_heating_boost on:general_an off:general_aus',
'cmdIcon' => 'auto:sani_heating_automatic manu:sani_heating_manual on:general_an off:general_aus',
'webCmd' => 'desired-temp:auto:manu:boost:on:off',
'widgetOverride' => 'desired-temp:slider,4.5,0.5,30.5,1'
},
'HEATING_CLIMATECONTROL_TRANSCEIVER' => {
'substexcl' => 'desired-temp',
'cmdIcon' => 'auto:sani_heating_automatic manu:sani_heating_manual boost:sani_heating_boost on:general_an off:general_aus',
'cmdIcon' => 'auto:sani_heating_automatic manu:sani_heating_manual on:general_an off:general_aus',
'webCmd' => 'desired-temp:auto:manu:boost:on:off',
'widgetOverride' => 'desired-temp:slider,4.5,0.5,30.5,1'
},
@ -862,15 +869,18 @@ $HMCCU_CONFIG_VERSION = '5.0';
},
'THERMALCONTROL_TRANSMIT' => {
'SET_TEMPERATURE' => { '4.5' => 'off', '30.5' => 'on' },
'WINDOW_OPEN_REPORTING' => { '0' => 'closed', '1' => 'open', 'false' => 'closed', 'true' => 'open' }
'WINDOW_OPEN_REPORTING' => { '0' => 'closed', '1' => 'open', 'false' => 'closed', 'true' => 'open' },
'BOOST_MODE' => { '0' => 'boostOff', '1' => 'boostOn', 'false' => 'boostOff', 'true' => 'boostOn' }
},
'CLIMATECONTROL_RT_TRANSCEIVER' => {
'SET_TEMPERATURE' => { '4.5' => 'off', '30.5' => 'on' }
'SET_TEMPERATURE' => { '4.5' => 'off', '30.5' => 'on' },
'BOOST_MODE' => { '0' => 'boostOff', '1' => 'boostOn', 'false' => 'boostOff', 'true' => 'boostOn' }
},
'HEATING_CLIMATECONTROL_TRANSCEIVER' => {
'SET_POINT_TEMPERATURE' => { '4.5' => 'off', '30.5' => 'on' },
'SET_POINT_MODE' => { '0' => 'auto', '1' => 'manual', '2' => 'boost', '3' => 'off' },
'WINDOW_STATE' => { '0' => 'closed', '1' => 'open', 'false' => 'closed', 'true' => 'open' }
'SET_POINT_MODE' => { '0' => 'auto', '1' => 'manual', '2' => 'party/holiday', '3' => 'off' },
'WINDOW_STATE' => { '0' => 'closed', '1' => 'open', 'false' => 'closed', 'true' => 'open' },
'BOOST_MODE' => { '0' => 'boostOff', '1' => 'boostOn', 'false' => 'boostOff', 'true' => 'boostOn' }
},
'CLIMATECONTROL_REGULATOR' => {
'SETPOINT' => { '4.5' => 'off', '30.5' => 'on' }