mqtt2

FHEM MQTT2 Shelly 2.5 shutter template

Just to make this easily copy & pasteable for me and possible others. here my template to connect my Shelly 2.5 for shutters to my FHEM via MQTT2 :). Just edit the MQTT path "shellies/gaestezimmer/rollo" and change the decive name "RolloGaestezimmer" and your good to go (don't forget to add your alexa device name and room to enable Echo binding :))

  # shelly25 using original firmware in roller mode.
  # contributed by 87insane, https://forum.fhem.de/index.php/topic,94060.msg940978.html#msg940978

  defmod RolloGaestezimmer MQTT2_DEVICE shelly25_rollo_gaestezimmer
  attr RolloGaestezimmer IODev HouseHive
  attr RolloGaestezimmer comment Shelly 2.5 in Roller-Mode. 100=opened / 0=closed
  attr RolloGaestezimmer setList \
    open:noArg shellies/gaestezimmer/rollo/roller/0/command open\
    close:noArg shellies/gaestezimmer/rollo/roller/0/command close\
    half:noArg shellies/gaestezimmer/rollo/roller/0/command/pos 50\
    stop:noArg shellies/gaestezimmer/rollo/roller/0/command stop\
    pct:slider,0,1,100 shellies/gaestezimmer/rollo/roller/0/command/pos $EVTPART1\
    x_recalibration:noArg shellies/gaestezimmer/rollo/roller/0/command rc\
    x_update:noArg shellies/gaestezimmer/rollo/command update_fw\
    x_mqttcom shellies/gaestezimmer/rollo/command $EVTPART1
  attr RolloGaestezimmer readingList \
    shellies/gaestezimmer/rollo/roller/0/pos:.* pct\
    shellies/gaestezimmer/rollo/status/0/rollers:.* power\
    shellies/gaestezimmer/rollo/online:.* online\
    shellies/gaestezimmer/rollo/announce:.* { json2nameValue($EVENT) }\
    shellies/announce:.* { $EVENT =~ m,..id...gaestezimmer/rollo...mac.*, ? json2nameValue($EVENT) : return }\
    shellies/gaestezimmer/rollo/roller/0:.* current\
    shellies/gaestezimmer/rollo/roller/0:open {{'state' => 'opening'}}\
    shellies/gaestezimmer/rollo/roller/0:close {{'state' => 'closing'}}\
    shellies/gaestezimmer/rollo/roller/0/pos:.* state\
    shellies/gaestezimmer/rollo/input/1:.* input1\
    shellies/gaestezimmer/rollo/input/0:.* input0\
    shellies/gaestezimmer/rollo/relay/power:.* power\
    shellies/gaestezimmer/rollo/relay/energy:.* energy\
    shellies/gaestezimmer/rollo/temperature:.* temperature\
    shellies/gaestezimmer/rollo/overtemperature:.* overtemperature\
    shellies/gaestezimmer/rollo/roller/0/power:.* roller_0_power\
    shellies/gaestezimmer/rollo/roller/0/energy:.* roller_0_energy\
    shellies/gaestezimmer/rollo/temperature_f:.* temperature_f
    
  attr RolloGaestezimmer cmdIcon open:fts_shutter_up close:fts_shutter_down stop:fts_shutter_manual half:fts_shutter_50
  attr RolloGaestezimmer webCmd :open:close:half:stop:pct
  deletereading -q RolloGaestezimmer (?!associatedWith).*
  attr RolloGaestezimmer setStateList open close half stop pct
  set RolloGaestezimmer x_mqttcom announce
  set RolloGaestezimmer attrTemplate speechcontrol_type_blind
  attr RolloGaestezimmer model shelly25_roller_invert_0
  setreading RolloGaestezimmer attrTemplateVersion 20200831


  attr RolloGaestezimmer devStateIcon { my $amp = ReadingsVal($name,"online","false") eq "false" ? "rot" : ReadingsVal($name,"new_fw","false") eq "true" ? "gelb" : "gruen"; my $con = ReadingsVal($name,"state","unknown"); $con = 100 - $con if $con =~ /\d+/; my $pic = $con eq "opening" ? 'fts_shutter_up@red' : $con eq "closing" ? 'fts_shutter_down@red' : $con eq "100" ? 'fts_shutter_100' : $con =~ /(\d)\d/ ? 'fts_shutter_'.$1.'0' : $con =~ /\b\d\b/ ? 'fts_shutter_10' : 'fts_shutter_updown'; my $show = "$amp" eq "gelb" ? "<a href=\"/fhem?cmd.dummy=set $name x_update&XHR=1\">".FW_makeImage("10px-kreis-".$amp)."</a>" : "<a href=\"http://".ReadingsVal($name,"ip","none")." \"target=\"_blank\">".FW_makeImage("10px-kreis-".$amp)."</a>"; "<div> $show <a href=\"/fhem?cmd.dummy=set $name toggle&XHR=1\"></a>".FW_makeImage($pic)." </div>"}