mqtt2.template: Contributing

Begonnen von Beta-User, 15 Dezember 2018, 11:45:40

Vorheriges Thema - Nächstes Thema

Dr. Boris Neubert

Hallo,

dieser Patch ergänzt den Aqara-Thermostat E1 (Aqara SRTS-A01) via zigbee2mqtt. Außerdem enthält er kleine Korrekturen an anderen Thermostat-Templates (getter darf kein Widget haben, Tippfehler im Template-Namen).

Viele Grüße
Boris
FHEM-Developer seit 2007, Förder-Mitglied des FHEM e.V.
Bitte keine unaufgeforderten privaten Nachrichten!

Beta-User

Thx, mit kleinen Anpassungen soeben eingecheckt.

(Anmerkung mehr an mich selbst: Diese ganzen kleineren Abweichungen zwischen den einzelnen Modellen sollte man doch eigentlich anders in den Griff bekommen wie jedes Mal die komplette Konfiguration mit zu pflegen, ziemlich unübersichtlisch...)
Server: HP-elitedesk@Debian 13, aktuelles FHEM@ConfigDB | CUL_HM (VCCU) | MQTT2: ZigBee2mqtt, MiLight@ESP-GW, BT@OpenMQTTGw | ZWave | SIGNALduino | MapleCUN | RHASSPY
svn: u.a Weekday-&RandomTimer, Twilight,  div. attrTemplate-files, MySensors

dadoc

#242
Hallo,
ich habe mich an einem Template für den Zigbee-Bodenfeuchte-Sensor versucht, den es für 5-6 Euro bei Ali gibt. Läuft bei mir:
#contributed by dadoc
name:zigbee2mqtt_Soil_Moisture_Sensor
desc: Soil Moisture sensor via zigbee2mqtt <br>Tested with: Coolo Soil moisture sensor sensor CS-201Z
filter:TYPE=MQTT2_DEVICE:FILTER=CID~zigbee.*
order:L_07b
par:BASE_TOPIC;base topic set in configuration.yaml of the zigbee2mqtt bridge;{ AttrVal("DEVICE","devicetopic",AttrVal("DEVICE","readingList","")) =~ m,[\b]?([^/:]+)[/].+, ? $1 : undef }
par:DEV_ID;name of the device in the zigbee2mqtt bridge;{ AttrVal("DEVICE","devicetopic",AttrVal("DEVICE","readingList","")) =~ m,[^/]+[/]([^/:]+).*, ? $1 : undef }
par:ICON;ICON as set, defaults to weather_pollen;{ AttrVal("DEVICE","icon","weather_pollen") }
attr DEVICE icon ICON
attr DEVICE stateFormat {sprintf ("Temp.: %.1f°C Hum.: %.1f%% Alert: %s Moisture: %.1f", ReadingsVal($name,"temperature",0), ReadingsVal($name,"humidity",0), ReadingsVal($name,"dry",0), ReadingsVal($name,"soil_moisture",0)) }
attr DEVICE devicetopic BASE_TOPIC/DEV_ID
attr DEVICE readingList $\DEVICETOPIC:.* { json2nameValue($EVENT,'',$JSONMAP) }
attr DEVICE setList \
  temperature_unit:celsius,fahrenheit $\DEVICETOPIC/set {"temperature_unit":"$EVTPART1"}\
  temperature_calibration:slider,-2,0.1,2,1 $\DEVICETOPIC/set {"temperature_calibration":$EVTPART1}\
  humidity_calibration:slider,-30,1,30 $\DEVICETOPIC/set {"humidity_calibration":$EVTPART1}\
  soil_calibration:slider,-30,1,30 $\DEVICETOPIC/set {"soil_calibration":$EVTPART1}\
  temperature_sampling:slider,5,1,3600 $\DEVICETOPIC/set {"temperature_sampling":$EVTPART1}\
  soil_sampling:slider,5,1,3600 $\DEVICETOPIC/set {"soil_sampling":$EVTPART1}\
  soil_warning:slider,0,1,100 $\DEVICETOPIC/set {"soil_warning":$EVTPART1}
deletereading -q DEVICE (?!associatedWith|IODev).*
attr DEVICE model zigbee2mqtt_Soil_Moisture_Sensor
setreading DEVICE attrTemplateVersion 20251101
Grüße
Martin
[Edit] Dezimalstellen beim Slider für temperature_calibration sichtbar gemacht.
Standort 1: FS20 mit CUL und FHEM auf Raspi. HM-Komponenten (Heizung, Rollladen, Schalter). HM IP über Raspimatic (testweise)
Standort 2: Homematic (Wired) über CCU2 und PocketHome HD
3 x Raspi3 mit piCorePlayer/Kodi für Multiroom Audio (+ Tablets/iPeng/iPods

Dr. Boris Neubert

Zitat von: dadoc am 02 November 2025, 18:00:33#contributed by dadoc
name:zigbee2mqtt_Soil_Moisture_Sensor
desc: Soil Moisture sensor via zigbee2mqtt <br>Tested with: Coolo Soil moisture sensor sensor CS-201Z

Danke, Martin! [OT]Wie lange läuft der, bis die Batterie getauscht werden muss?[/OT]
FHEM-Developer seit 2007, Förder-Mitglied des FHEM e.V.
Bitte keine unaufgeforderten privaten Nachrichten!

scooty

#244
Hier mein Template für einen Zigbee Hobeian Rain illuminance sensor ZG-223Z.
#contributed by Scooty
name:zigbee2mqtt_Rain_Illuminance_Sensor
desc: Rain Illuminance sensor via zigbee2mqtt <br>Tested with: Hobeian Rain illuminance sensor ZG-223Z
filter:TYPE=MQTT2_DEVICE:FILTER=CID~zigbee.*
order:L_10b
par:BASE_TOPIC;base topic set in configuration.yaml of the zigbee2mqtt bridge;{ AttrVal("DEVICE","devicetopic",AttrVal("DEVICE","readingList","")) =~ m,[\b]?([^/:]+)[/].+, ? $1 : undef }
par:DEV_ID;name of the device in the zigbee2mqtt bridge;{ AttrVal("DEVICE","devicetopic",AttrVal("DEVICE","readingList","")) =~ m,[^/]+[/]([^/:]+).*, ? $1 : undef }
par:ICON;ICON as set, defaults to weather_rain_gauge;{ AttrVal("DEVICE","icon","weather_rain_gauge") }
attr DEVICE icon ICON
attr DEVICE stateFormat rainwater
attr DEVICE devStateIcon raining:weather_rain@green .*:weather_sun@red
attr DEVICE devicetopic BASE_TOPIC/DEV_ID
attr DEVICE readingList $\DEVICETOPIC:.* { json2nameValue($EVENT,'',$JSONMAP) }
attr DEVICE setList \
  sensitivity:slider,0,1,9 $\DEVICETOPIC/set {"sensitivity":$EVTPART1}\
  illuminance_sampling:slider,1,1,480 $\DEVICETOPIC/set {"illuminance_sampling":$EVTPART1}
deletereading -q DEVICE (?!associatedWith|IODev).*
attr DEVICE model zigbee2mqtt_Rain_Illuminance_Sensor
setreading DEVICE attrTemplateVersion 20251122

Genial: Regenschnellerkennung
Nicht so genial: CR232 Batterie, aber irgendwas ist ja immer ;) , Laufzeiterfahrung habe ich aber noch nicht.
Fhem auf Gigabyte Brix
CUL V3 HM / CUL V3 MAX / MaxCube aFW Homematic&MAX / ZWave.me ZME_UZB1 / SDuino 433 / Velux KLF200
Homematic / MAX / Logitech Hub / ZWave / Wifi LED / div. 433 Temperatursensoren / pywws WH1080 / IO Homecontrol

offebaescher

Hallo zusammen, ich bin nicht so der Coding Guru und weiß nicht ob ich das alles richtig gemacht habe.

Ich habe einen Heizkörperthermostat von AVATTO, Modell TRV06, im Detail "TZE284_o3x45p96" bei der berühmten chinesischen Handelsplattform testweise bestellt und konnte das Gerät sehr erfolgreich in Betrieb nehmen via Zigbee2MQTT und soweit alles damit machen, was ich brauche. Also entweder es in den "auto" Modus versetzen und es die maximal 6 Transitions pro Tag durchlaufen lassen (Format: "HH:MM/C HH:MM/C HH:MM/C HH:MM/C HH:MM/C HH:MM/C"), oder es in den "heat" Modus versetzen und die desired-temp jeweils setzen durch FHEM.

Zigbee-Modell TS0601
_TZE284_o3x45p96 (Thermostatic radiator valve)
Modell TRV06_1 AVATTO
https://www.zigbee2mqtt.io/devices/TRV06_1.html

Ich hatte mich an dem bestehenden Template "zigbee2mqtt_thermostat_with_weekprofile" orientiert. Dieses Gerät hat allerdings nicht die Profiles holidays und workdays sondern schedule_monday bis schedule_sunday. Ausserdem kann man noch die Werte local_temperature_calibration, frost_protection und scale_protection setzen. Mit dem battery_low bin ich noch unsicher wie das funktioniert, es wird nur gesendet, wenn die battery_low ist, solange das nicht der Fall ist, ist das reading nicht existent und wird mir nicht angezeigt.

#contributed by offebaescher
name:zigbee2mqtt_thermostat_AVATTO_TRV06_TS0601
desc: Developed for AVATTO TRV06 TS0601 (Thermostatic radiator valve)
filter:TYPE=MQTT2_DEVICE:FILTER=CID~zigbee.*
order:L_17c
par:BASE_TOPIC;base topic set in configuration.yaml of the zigbee2mqtt bridge;{ AttrVal("DEVICE","devicetopic",AttrVal("DEVICE","readingList","")) =~ m,[\b]?([^/:]+)[/].+, ? $1 : undef }
par:DEV_ID;name of the device in the zigbee2mqtt bridge;{ AttrVal("DEVICE","devicetopic",AttrVal("DEVICE","readingList","")) =~ m,[^/]+[/]([^/:]+).*, ? $1 : undef }
par:ICON;ICON as set, defaults to temp_control;{ AttrVal("DEVICE","icon","temp_control") }
par:WPNAME;weekprofile attr value, defaults to device name;{ AttrVal("DEVICE","weekprofile","DEVICE") }
farewell:template has been applied successfully. NOTE: code has been downloaded from svn (contrib). For use with weekprofile, additional configuration is needed!
{ Svn_GetFile("contrib/AttrTemplate/99_attrT_z2m_thermostat_Utils.pm", "FHEM/99_attrT_z2m_thermostat_Utils.pm", sub(){ CommandReload(undef, "99_attrT_z2m_thermostat_Utils.pm") }) }
attr DEVICE comment For use with weekprofile, additional configuration is needed, 6 Transitions required, format example: "HH:MM/C HH:MM/C HH:MM/C HH:MM/C HH:MM/C HH:MM/C"
attr DEVICE icon ICON
attr DEVICE devicetopic BASE_TOPIC/DEV_ID
attr DEVICE userattr weekprofile
attr DEVICE weekprofile WPNAME
attr DEVICE readingList $\DEVICETOPIC:.* { my %h; my $temp = $EVENT; $temp =~ s/,?("(holidays|workdays)":.([^]]+))./$h{$2}=$3/ge; $EVENT =~ s/,?("(holidays|workdays)":.([^]]+)).//g; my $h2 = json2nameValue($EVENT,'',$JSONMAP); %h = (%h,%$h2); \%h }
attr DEVICE setList\
  desired-temp:slider,5.0,0.5,30.0,1 $\DEVICETOPIC/set {"current_heating_setpoint": $EVTPART1 }\
  child_lock:LOCK,UNLOCK $\DEVICETOPIC/set {"child_lock": "$EVTPART1"}\
  schedule_monday:textField { my $payload = $EVENT;$payload =~ s/$EVTPART0 //; qq($\DEVICETOPIC/set {"schedule_monday":"$payload"})}\
  schedule_tuesday:textField { my $payload = $EVENT;$payload =~ s/$EVTPART0 //; qq($\DEVICETOPIC/set {"schedule_tuesday":"$payload"})}\
  schedule_wednesday:textField { my $payload = $EVENT;$payload =~ s/$EVTPART0 //; qq($\DEVICETOPIC/set {"schedule_wednesday":"$payload"})}\
  schedule_thursday:textField { my $payload = $EVENT;$payload =~ s/$EVTPART0 //; qq($\DEVICETOPIC/set {"schedule_thursday":"$payload"})}\
  schedule_friday:textField { my $payload = $EVENT;$payload =~ s/$EVTPART0 //; qq($\DEVICETOPIC/set {"schedule_friday":"$payload"})}\
  schedule_saturday:textField { my $payload = $EVENT;$payload =~ s/$EVTPART0 //; qq($\DEVICETOPIC/set {"schedule_saturday":"$payload"})}\
  schedule_sunday:textField { my $payload = $EVENT;$payload =~ s/$EVTPART0 //; qq($\DEVICETOPIC/set {"schedule_sunday":"$payload"})}\
  mode:heat,auto,off $\DEVICETOPIC/set {"system_mode": "$EVTPART1"}\
  pi_heating_demand:slider,0,1,100,1 $\DEVICETOPIC/set {"pi_heating_demand": $EVTPART1 }\
  frost_protection:ON,OFF $\DEVICETOPIC/set {"frost_protection": "$EVTPART1"}\
  scale_protection:ON,OFF $\DEVICETOPIC/set {"scale_protection": "$EVTPART1"}\
  local_temperature_calibration:slider,-9.0,1,9.0,1 $\DEVICETOPIC/set {"local_temperature_calibration": $EVTPART1 }\
  x_send_set_payload:textField { my $payload = $EVENT;$payload =~ s/$EVTPART0 //; qq($\DEVICETOPIC/set $payload)}
attr DEVICE getList desired-temp:noArg desired-temp $\DEVICETOPIC/get {"current_heating_setpoint": ""}\
  temperature:noArg temperature $\DEVICETOPIC/get {"local_temperature": ""}\
  preset:noArg preset $\DEVICETOPIC/get {"preset": ""}
attr DEVICE stateFormat Measured: temperature Desired: desired-temp \
  Battery: batteryState child_lock
attr DEVICE devStateIcon LOCKED:secur_lock:btnLock+UNLOCK UNLOCKED:secur_open:btnLock+LOCK
attr DEVICE webCmd desired-temp
attr DEVICE widgetOverride desired-temp@set:knob,min:5,max:30,angleArc:180,width:40,height:40,fgColor:#FF9900,bgColor:#CCCCCC,step:0.5,lineCap:round,angleOffset:225
attr DEVICE jsonMap current_heating_setpoint:desired-temp local_temperature:temperature Battery:battery_low system_mode:mode
attr DEVICE setStateList on off
attr DEVICE userReadings batteryState:battery_low.* {ReadingsVal($name,'battery_low','false')}
attr DEVICE model zigbee2mqtt_thermostat_AVATTO_TRV06_TS0601
set DEVICE attrTemplate speechcontrol_type_thermostat
deletereading -q DEVICE (?!associatedWith|IODev).*
setreading DEVICE attrTemplateVersion 20251208

Vielleicht ist das ja für jemanden nützlich.