Permalink
Browse files

hcanhab: Schnittstelle fuer die Bedienung der Heizung erweitert

  • Loading branch information...
ingo ingo
ingo authored and ingo committed Jan 8, 2018
1 parent 35e6e9f commit c0d0925595a9d172f4012bf388f7a402f33d1240
View
@@ -88,10 +88,13 @@ int getMessage4cb (char * msg, struct can_frame * msg4cb)
token = strtok(NULL, "/"); if(NULL == token) return 0;
msg4cb->data[2] = atoi(token); // Heizungs-ID
token = strtok(NULL, "/"); if(NULL == token) return 0;
uint16_t temp = (uint16_t) (16 * atof(token));
uint16_t temp = (uint16_t) (16.0f * atof(token));
msg4cb->data[3] = temp>>8; // temp_hi : Soll-Temperatur (MSB)
msg4cb->data[4] = temp; // temp_li : Soll-Temperatur (LSB)
uint16_t dauer = 65000; // TODO von OH erhalten!
uint16_t dauer = 0; // 0 = ohne Zeitangabe unbegrenzt (falls der naechste Token fehlt)
token = strtok(NULL, "/");
if(NULL != token) dauer = (uint16_t) (3600.0f * atof(token)); // hours -> secs
msg4cb->data[5] = dauer>>8; // duration_hi : Restdauer (MSB), 0 = unbegrenzt
msg4cb->data[6] = dauer; // duration_lo : Restdauer (LSB)
return 7;
@@ -153,6 +156,7 @@ static inline uint8_t isItTopic4Broker(uint8_t msg4broker)
size_t catHesTopic4Broker(char * str, const struct can_frame * cf)
{
float temp = 0;
float dauer = 0;
const size_t maxSize = 30;
switch (cf->data[1])
{
@@ -190,8 +194,9 @@ size_t catHesTopic4Broker(char * str, const struct can_frame * cf)
case HCAN_HES_HEIZUNG_MODE_OFF_DETAILS:
return snprintf(str, maxSize, "%d/H/aus", cf->data[2]);
case HCAN_HES_HEIZUNG_MODE_THERMOSTAT_DETAILS:
temp = ((cf->data[3]<<8)|cf->data[4]) / 16.0; // Temperaturwert
return snprintf(str, maxSize, "%d/H/therm/%.1f", cf->data[2], temp);
temp = (float)((cf->data[3]<<8)|cf->data[4]) / 16.0; // Temperaturwert
dauer = (float)((cf->data[5]<<8)|cf->data[6]) / 3600.0; // Dauer
return snprintf(str, maxSize, "%d/H/therm/%.1f/%.1f", cf->data[2], temp, dauer);
case HCAN_HES_HEIZUNG_MODE_AUTOMATIK_DETAILS:
temp = ((cf->data[3]<<8)|cf->data[4]) / 16.0; // Temperaturwert
return snprintf(str, maxSize, "%d/H/auto/%.1f", cf->data[2], temp);
@@ -22,9 +22,9 @@ cb> 91/OPEN
cb> 91/CLOSED
cb> 91/H/aus
cb> 91/H/therm/20.6
cb> 91/H/auto/20.6
cb> 91/H/therm/20.6 ohne Zeitangabe unbegrenzt
cb> 91/H/therm/20.6/2.5 2.5= fuer 2.5h
schalten:
---------
@@ -13,8 +13,10 @@ smarthome:status LAMPE_OG_Buero__Decke_Schraege
smarthome:status LAMPE_OG_Buero__Decke_Tuer
smarthome:status LAMPE_EG_Bad__Decke
smarthome:status TEMPERATUR_OG_K2__K2
smarthome:status TEMPERATUR_OG_K1__K1_Heizung
smarthome:status TEMPERATUR_OG_K1__K1
smarthome:status SOLLDAUER_OG_K1__K1
smarthome:status SOLLTEMP_OG_K1__K1
smarthome:status HEIZMODE_OG_K1__K1
smarthome:send LAMPE_OG_Buero__Decke_Tuer ON
---
@@ -23,6 +23,5 @@ moveIt:
rm -f -R $(OPENHABDOWNLOADS_DIR)/tempinst
start:
make stop
sh /home/$(ZIEL_USER)/$(ZIEL_ORDNER)/start.sh
@# sh /home/$(ZIEL_USER)/$(ZIEL_ORDNER)/start_debug.sh
@@ -1,13 +1,22 @@
/* Bsp. input: '148/H/aus/16°C' mit 148=gruppe
output Mode: 1, 2, 3 als String */
var res = input.split("/",3);
/* Bsp. input: '148/H/therm/16.5/2.8' mit 148=gruppe
output Mode: 1,2,3,33,4,5 als String */
var res = input.split("/",5);
var rtn = "ng";
// Mode ermitteln:
if (res[2] === "aus") rtn = "1";
else if (res[2] === "auto") rtn = "2";
else if (res[2] === "therm") {
// TODO genauer unterscheiden: Frostschutz, kurz, theorisch abh von Zeit und Temp
rtn = "3";
else if (res[2] === "therm")
{
if (res[3] > 10.0)
{
if (Math.round(res[4]) === 0.0) rtn = "3"; // 0= dauer unbegrenzt
else rtn = "33"; // sonst vermutlich 3h
}
else
{
if (Math.round(res[4]) === 0.0) rtn = "4"; // 0= dauer unbegrenzt
else rtn = "34"; // sonst vermutlich 3h
}
}
rtn;
@@ -26,9 +26,6 @@ RULE_FILES := $(patsubst rules_%.xsl,%.rules,$(wildcard rules_*.xsl))
all.rules: $(RULE_FILES)
echo RULE_FILES: $(RULE_FILES)
#
cat ../generated/heizungGlobalVariablen.rules ../generated/heizung.rules > ../generated/heizung_cat.rules
cd ../generated/; rm -f heizungGlobalVariablen.rules heizung.rules
$(RULE_FILES): %.rules: rules_%.xsl
xalan -in $(HCAN_INSTALLATION) -xsl $< > ../generated/$@
@@ -28,16 +28,9 @@
Group <xsl:value-of select="substring-before(@name,'__')" /> "<xsl:value-of select="@stt" />" (Heizungen) [ "Thermostat" ]
Number TEMPERATUR_<xsl:value-of select="@name" /> "<xsl:value-of select="substring-after(@name,'__')" /> [%.1f °C]" &lt;temperature&gt; (<xsl:value-of select="substring-before(@name,'__')" />) [ "CurrentTemperature" ] {mqtt="&lt;[bpiBroker:cb&gt;:state:JS(getTemp.js):<xsl:value-of select="@gruppe" />/T/.*]", autoupdate="true"}
Number SOLLTEMP_<xsl:value-of select="@name" /> &lt;temperature&gt; (<xsl:value-of select="substring-before(@name,'__')" />) [ "TargetTemperature" ] {mqtt="&lt;[bpiBroker:cb&gt;:state:JS(getSolltemp.js):<xsl:value-of select="@gruppe" />/H/(auto|therm)/.*], &gt;[bpiBroker:cb&lt;:command:*:H/therm/<xsl:value-of select="@gruppe" />/${command}]", autoupdate="true"}
String SOLLTEMP_DAUER_<xsl:value-of select="@name" /> {mqtt="&gt;[bpiBroker:cb&lt;:command:*:H/therm/<xsl:value-of select="@gruppe" />/${command}]"}
String HEIZMODE_<xsl:value-of select="@name" /> "<xsl:value-of select="substring-after(@name,'__')" />" &lt;heating&gt; (<xsl:value-of select="substring-before(@name,'__')" />) [ "homekit:HeatingCooling" ] {mqtt="&lt;[bpiBroker:cb&gt;:state:JS(getHeizmodeState.js):<xsl:value-of select="@gruppe" />/H/.*], &gt;[bpiBroker:cb&lt;:command:1:H/aus/<xsl:value-of select="@gruppe" />], &gt;[bpiBroker:cb&lt;:command:2:H/auto/<xsl:value-of select="@gruppe" />]", autoupdate="true"}
/* OH-Bsp von https://github.com/openhab/openhab-alexa
Group gDownstairsThermostat "Downstairs Thermostat" (gFF) [ "Thermostat" ]
Number DownstairsThermostatCurrentTemp "Downstairs Thermostat Current Temperature" (gDownstairsThermostat) [ "CurrentTemperature" ]
Number DownstairsThermostatTargetTemperature "Downstairs Thermostat Target Temperature" (gDownstairsThermostat) [ "TargetTemperature" ]
String DownstairsThermostatHeatingCoolingMode "Downstairs Thermostat Heating/Cooling Mode" (gDownstairsThermostat) [ "homekit:HeatingCooling" ]
*/
</xsl:template>
@@ -37,8 +37,7 @@ Frame {
<xsl:for-each select="board/heizung | raum/board/heizung">
<xsl:if test="(@sammel != '-')">
Frame label="<xsl:value-of select="@stt" />-Heizung: " {
Selection item=HEIZMODE_<xsl:value-of select="@name" /> label="Heiz-Modus" icon="heating" mappings=["1"="aus", "2"="auto", "3"="therm (3 Std.)", "4"="✳ (3 Std.)", "5"="✳"]
//Switch item=SOLLTEMP_<xsl:value-of select="@name" /> label="[soll: %.1f °C]" icon="temperature" mappings=["0"="−", "1"="+"]
Selection item=HEIZMODE_<xsl:value-of select="@name" /> label="Heiz-Modus" icon="heating" mappings=["1"="aus", "2"="auto", "3"="therm", "33"="therm (3h)", "4"="✳", "34"="✳ (3h)"]
Setpoint item=SOLLTEMP_<xsl:value-of select="@name" /> label=" [%.1f °C]" icon="temperature" minValue=6 maxValue=30 step=0.5
}
</xsl:if>
@@ -129,8 +128,7 @@ Frame {
<xsl:template match="heizung">
Frame label="<xsl:value-of select="@stt" />-Heizung: " {
Selection item=HEIZMODE_<xsl:value-of select="@name" /> label="Heiz-Modus" icon="heating" mappings=["1"="aus", "2"="auto", "3"="therm (3 Std.)", "4"="✳ (3 Std.)", "5"="✳"]
// Switch item=SOLLTEMP_<xsl:value-of select="@name" /> label="[soll: %.1f °C]" icon="temperature" mappings=["0"="−", "1"="+"]
Selection item=HEIZMODE_<xsl:value-of select="@name" /> label="Heiz-Modus" icon="heating" mappings=["1"="aus", "2"="auto", "3"="therm", "33"="therm (3h)", "4"="✳", "34"="✳ (3h)"]
Setpoint item=SOLLTEMP_<xsl:value-of select="@name" /> label=" [%.1f °C]" icon="temperature" minValue=6 maxValue=30 step=0.5
}
</xsl:template>
@@ -21,39 +21,35 @@ rule "Heizung OpenHab-Selektion veraendert"
when
Item HEIZMODE_<xsl:value-of select="@name" /> received command
then
//logInfo("IL-HM", "HEIZMODE_<xsl:value-of select="@name" />: " + receivedCommand.toString)
if(receivedCommand == "1") { // Aus
logInfo("IL-HM", "HEIZMODE_<xsl:value-of select="@name" />: Aus")
// HEIZMODE_<xsl:value-of select="@name" />.sendCommand("1")
sollTemp<xsl:value-of select="@name" /> = 0
SOLLTEMP_<xsl:value-of select="@name" />.postUpdate(sollTemp<xsl:value-of select="@name" />) // sitemap-Aktu.
SOLLTEMP_<xsl:value-of select="@name" />.postUpdate(0) // "sitemap-Aktu."
return
}
else if(receivedCommand == "2") { // Auto
logInfo("IL-HM", "HEIZMODE_<xsl:value-of select="@name" />: Auto")
// HEIZMODE_<xsl:value-of select="@name" />.sendCommand("2")
return
}
else if(receivedCommand == "3") { // Therm
logInfo("IL-HM", "HEIZMODE_<xsl:value-of select="@name" />: Therm")
sollTemp<xsl:value-of select="@name" /> = 20.5
logInfo("IL-HM", "HEIZMODE_<xsl:value-of select="@name" />: Therm unbegr")
SOLLTEMP_<xsl:value-of select="@name" />.postUpdate(20.5) // "sitemap-Aktu."
SOLLTEMP_DAUER_<xsl:value-of select="@name" />.sendCommand("20.5/0.0") // mqtt-cmd (0= fuer unbegrenzte Zeit)
}
else if(receivedCommand == "33") { // Therm (3 Std.)
logInfo("IL-HM", "HEIZMODE_<xsl:value-of select="@name" />: Therm 3h")
SOLLTEMP_<xsl:value-of select="@name" />.postUpdate(20.5) // "sitemap-Aktu."
SOLLTEMP_DAUER_<xsl:value-of select="@name" />.sendCommand("20.5/3.0") // mqtt-cmd
}
else if(receivedCommand == "4") { // ✳ (3 Std.)
logInfo("IL-HM", "HEIZMODE_<xsl:value-of select="@name" />: Frost kurz")
// TODO Schnittstelle zu mqttPahoClient erweitern um Dauer
sollTemp<xsl:value-of select="@name" /> = 10
else if(receivedCommand == "4") {
logInfo("IL-HM", "HEIZMODE_<xsl:value-of select="@name" />: Frost unbegr")
SOLLTEMP_<xsl:value-of select="@name" />.postUpdate(10) // "sitemap-Aktu."
SOLLTEMP_DAUER_<xsl:value-of select="@name" />.sendCommand("10/0.0") // mqtt-cmd (0= fuer unbegrenzte Zeit)
}
else if(receivedCommand == "5") { // ✳ lange
logInfo("IL-HM", "HEIZMODE_<xsl:value-of select="@name" />: Frost lang")
// TODO Schnittstelle zu mqttPahoClient erweitern um Dauer
sollTemp<xsl:value-of select="@name" /> = 10
}
logInfo("IL@HM Solltemp angepasst ", "sollTemp<xsl:value-of select="@name" />: " + sollTemp<xsl:value-of select="@name" />.toString)
//SOLLTEMP_<xsl:value-of select="@name" />.postUpdate(sollTemp<xsl:value-of select="@name" />) // sitemap-Aktu.
SOLLTEMP_<xsl:value-of select="@name" />.sendCommand(sollTemp<xsl:value-of select="@name" />) // mqtt-cmd
else if(receivedCommand == "34") { // ✳ (3 Std.)
logInfo("IL-HM", "HEIZMODE_<xsl:value-of select="@name" />: Frost 3h")
SOLLTEMP_<xsl:value-of select="@name" />.postUpdate(10) // "sitemap-Aktu."
SOLLTEMP_DAUER_<xsl:value-of select="@name" />.sendCommand("10/3.0") // mqtt-cmd
}
end
</xsl:template>

This file was deleted.

Oops, something went wrong.

0 comments on commit c0d0925

Please sign in to comment.