From 562f90c6476bd8b83f403f6b2219b50d325526f3 Mon Sep 17 00:00:00 2001 From: Beta-User <> Date: Thu, 5 Mar 2020 18:18:57 +0000 Subject: [PATCH] mqtt2.template: change in tasmotar gbw template, add weewx template; change speech recogn testing git-svn-id: https://svn.fhem.de/fhem/trunk@21360 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/lib/AttrTemplate/mqtt2.template | 38 ++++++++++++++++++- .../lib/AttrTemplate/speechrecogn.template | 20 ++++++---- 2 files changed, 48 insertions(+), 10 deletions(-) diff --git a/fhem/FHEM/lib/AttrTemplate/mqtt2.template b/fhem/FHEM/lib/AttrTemplate/mqtt2.template index 93d078bfb..ee07cf522 100644 --- a/fhem/FHEM/lib/AttrTemplate/mqtt2.template +++ b/fhem/FHEM/lib/AttrTemplate/mqtt2.template @@ -310,7 +310,7 @@ attr DEVICE icon ICON attr DEVICE stateFormat T: temperature_weather B: illuminance L: linkquality attr DEVICE readingList BASE_TOPIC/DEV_ID:.* { json2nameValue($EVENT) } attr DEVICE userReadings temperature_weather { sprintf("%.1f",ReadingsVal($name,"temperature","")+2.5) } -set DEVICE attrTemplate speech_recognition_gdt_and_mapping GENERICDEVICETYPE=motion HOMEBRIDGEMAPPING="MotionDetected=state,values=motion:1;nomotion:0" +set DEVICE attrTemplate speech_recognition_gdt_and_mapping GENERICDEVTYPE=motion HOMEBRIDGEMAPPING="MotionDetected=state,values=motion:1;nomotion:0" attr DEVICE model zigbee2mqtt_hueMotionSensor name:zigbee2mqtt_plug @@ -1134,7 +1134,8 @@ attr DEVICE setList\ toggle:noArg CMNDTOPIC/POWER1 2\ Color:colorpicker,RGB CMNDTOPIC/COLOR\ pct:colorpicker,BRI,0,5,100 CMNDTOPIC/DIMMER\ - white:colorpicker,BRI,0,5,100 { "CMNDTOPIC/COLOR ". sprintf("000000%02X",$EVTPART1*2.55) } + white:colorpicker,BRI,0,5,100 { "CMNDTOPIC/COLOR ". sprintf("000000%02X",$EVTPART1*2.55) }\ + saturation:colorpicker,BRI,0,1,100 CMNDTOPIC/HSBCOLOR2\ attr DEVICE readingList \ TELETOPIC/LWT:.* LWT\ TELETOPIC/STATE:.* { json2nameValue($EVENT,'',$JSONMAP) }\ @@ -1142,6 +1143,7 @@ attr DEVICE readingList \ TELETOPIC/INFO.:.* { json2nameValue($EVENT,'',$JSONMAP) }\ TELETOPIC/UPTIME:.* { json2nameValue($EVENT,'',$JSONMAP) }\ STATTOPIC/RESULT:.* { json2nameValue($EVENT,'',$JSONMAP) }\ + STATTOPIC/RESULT:.* { $EVENT =~ m,HSBColor...(\d+)\,(\d+)\,(\d+), ? $2 eq ReadingsVal($NAME,"saturation","unknown") ? undef :{"saturation"=>$2} : undef }\ STATTOPIC/POWER1:.* state attr DEVICE jsonMap POWER1:0 Dimmer:pct Channel_4:white Channel_1:0 Channel_2:0 Channel_3:0 HSBColor:0 attr DEVICE webCmd pct:white:Color @@ -2683,6 +2685,38 @@ attr DEVICE comment For further info on configuration and available commands see farewell:template has been applied successfully. For further info on configuration and available commands see project page. attr DEVICE model wallpanel_app +name:weewx_weather_station +filter:TYPE=MQTT2_DEVICE +desc:See source post: https://forum.fhem.de/index.php/topic,108815.msg1027867.html#msg1027867 for details. For setting up weewx for MQTT use see https://github.com/weewx/weewx/wiki/mqtt +order:X_20 +par:BASE_ID;BASE_ID typically is weather;{ AttrVal("DEVICE","readingList","") =~ m,(weather)[/][^/]+[/].*:, ? $1 : undef } +par:ICON;ICON as set, defaults to weather_station;{ AttrVal("DEVICE","icon","weather_station") } +attr DEVICE icon ICON +attr DEVICE event-on-change-reading .* +attr DEVICE readingList BASE_ID/outTemp_C:.* temperature\ + BASE_ID/cloudbase_meter:.* cloudbase\ + BASE_ID/outHumidity:.* humidity\ + BASE_ID/pressure_mbar:.* pressure\ + BASE_ID/rain_mm:.* rainfall\ + BASE_ID/barometer_mbar:.* barometer\ + BASE_ID/dewpoint_C:.* dewpoint\ + BASE_ID/rainTotal:.* rainTotal\ + BASE_ID/heatindex_C:.* heatindex\ + BASE_ID/dayRain_mm:.* day_rain\ + BASE_ID/inDewpoint:.* in_dewpoint\ + BASE_ID/altimeter_mbar:.* altimeter\ + BASE_ID/appTemp_C:.* appTemp\ + BASE_ID/windGust_mps:.* wind_gust\ + BASE_ID/rain24_mm:.* rain_24h\ + BASE_ID/hourRain_mm:.* rain_1h\ + BASE_ID/windSpeed_mps:.* wind\ + BASE_ID/rainRate_mm_per_hour:.* rainrate\ + BASE_ID/windDir:.* winddir\ + BASE_ID/inHumidity:.* in_humidity +attr DEVICE stateFormat T: temperature°C, H: humidity%rH, P: barometer hPa +deletereading -q DEVICE (?!associatedWith).* +attr DEVICE model weewx_weather_station + #source post: https://forum.fhem.de/index.php/topic,98880.msg995308.html#msg995308 name:wled_controller filter:TYPE=MQTT2_DEVICE diff --git a/fhem/FHEM/lib/AttrTemplate/speechrecogn.template b/fhem/FHEM/lib/AttrTemplate/speechrecogn.template index 5406e4156..91bfa46a3 100644 --- a/fhem/FHEM/lib/AttrTemplate/speechrecogn.template +++ b/fhem/FHEM/lib/AttrTemplate/speechrecogn.template @@ -13,10 +13,10 @@ # perl_code returns a value for the parameter, or undef. # If undef, the user has to specify them (the comment is shown to the user) -#original name:speech_recognition_type_switch name:speech_recognition_type_switch filter:NAME=speechrecognTesting order:100001 +desc:template to set speech recognition attributes for genericDeviceType switch option:{my @devices=devspec2array("TYPE=(siri|alexa|gassistant)");;return 1 if $devices[0];;return 0} attr DEVICE genericDeviceType switch option:TYPE=siri @@ -26,6 +26,7 @@ option:TYPE=gassistant name:speech_recognition_type_light filter:NAME=speechrecognTesting order:100002 +desc:template to set speech recognition attributes for genericDeviceType light option:{my @devices=devspec2array("TYPE=(siri|alexa|gassistant)");;return 1 if $devices[0];;return 0} attr DEVICE genericDeviceType light option:TYPE=siri @@ -35,6 +36,7 @@ option:TYPE=gassistant name:speech_recognition_type_light_255 filter:NAME=speechrecognTesting order:100003 +desc:template to set speech recognition attributes for genericDeviceType light - brightness in 255 steps option:{my @devices=devspec2array("TYPE=(siri|alexa|gassistant)");;return 1 if $devices[0];;return 0} set DEVICE attrTemplate speech_recognition_type_light #par:NEWUSERREADINGS;NEWUSERREADINGS as set if sr_brightness is included, otherwise it will be added;{ my $old = AttrVal("DEVICE","userReadings",undef);; !defined $old ? 'sr_brightness:brightness.* {sprintf("%.0f", ReadingsNum("$name","brightness",0)/255*100)}' : $old =~ m,sr_brightness:brightness.*, ? $old : $old.', sr_brightness:brightness.* {sprintf("%.0f", ReadingsNum("$name","brightness",0)/255*100)}' } @@ -48,6 +50,7 @@ option:TYPE=gassistant name:speech_recognition_type_blind filter:NAME=speechrecognTesting order:100004 +desc:template to set speech recognition attributes for genericDeviceType blind option:{my @devices=devspec2array("TYPE=(siri|alexa|gassistant)");;return 1 if $devices[0];;return 0} attr DEVICE genericDeviceType blind option:TYPE=siri @@ -57,6 +60,7 @@ option:TYPE=gassistant name:speech_recognition_type_thermostate filter:NAME=speechrecognTesting order:100005 +desc:template to set speech recognition attributes for genericDeviceType thermostate option:{my @devices=devspec2array("TYPE=(siri|alexa|gassistant)");;return 1 if $devices[0];;return 0} attr DEVICE genericDeviceType thermostate option:TYPE=siri @@ -66,10 +70,10 @@ option:TYPE=gassistant name:speech_recognition_gdt_only filter:NAME=speechrecognTesting order:100006 -desc:call e.g. with set attrTemplate speech_recognition_gdt_only GENERICDEVICETYPE=Security +desc:template to set speech recognition attributes for to any genericDeviceType; call e.g. with set attrTemplate speech_recognition_gdt_only GENERICDEVTYPE=Security option:{my @devices=devspec2array("TYPE=(siri|alexa|gassistant)");;return 1 if $devices[0];;return 0} -par:GENERICDEVICETYPE;GENERICDEVICETYPE , defaults to contact;{ "contact" } -attr DEVICE genericDeviceType GENERICDEVICETYPE +par:GENERICDEVTYPE;GENERICDEVTYPE , defaults to contact;{ "contact" } +attr DEVICE genericDeviceType GENERICDEVTYPE option:TYPE=siri option:TYPE=alexa option:TYPE=gassistant @@ -77,11 +81,11 @@ option:TYPE=gassistant name:speech_recognition_gdt_and_mapping filter:NAME=speechrecognTesting order:100007 -desc:call e.g. with set xy attrTemplate speech_recognition_gdt_and_mapping GENERICDEVICETYPE=Security HOMEBRIDGEMAPPING= "ContactSensorState=state,values=closed:CONTACT_DETECTED;;open:CONTACT_NOT_DETECTED" +desc:generic template to set speech recognition attributes for to any genericDeviceType including full mapping, call e.g. with set xy attrTemplate speech_recognition_gdt_and_mapping GENERICDEVTYPE=Security HOMEBRIDGEMAPPING= "ContactSensorState=state,values=closed:CONTACT_DETECTED;;open:CONTACT_NOT_DETECTED" option:{my @devices=devspec2array("TYPE=(siri|alexa|gassistant)");;return 1 if $devices[0];;return 0} -par:GENERICDEVICETYPE;GENERICDEVICETYPE , defaults to contact;{ "contact" } -par:HOMEBRIDGEMAPPING;HOMEBRIDGEMAPPING, defaults to "ContactSensorState=state,values=closed:CONTACT_DETECTED;;open:CONTACT_NOT_DETECTED";{ "ContactSensorState=state,values=closed:CONTACT_DETECTED;;open:CONTACT_NOT_DETECTED" } -attr DEVICE genericDeviceType GENERICDEVICETYPE +par:GENERICDEVTYPE;GENERICDEVTYPE , defaults to contact;{ "contact" } +par:HOMEBRIDGEMAPPING;HOMEBRIDGEMAPPING, defaults to "some split-by-semicolon-compatible represantation or the expression to the right";{ 'ContactSensorState=state,values=closed:CONTACT_DETECTED;;open:CONTACT_NOT_DETECTED'" } +attr DEVICE genericDeviceType GENERICDEVTYPE attr DEVICE homebridgeMapping HOMEBRIDGEMAPPING option:TYPE=siri option:TYPE=alexa