diff --git a/fhem/CHANGED b/fhem/CHANGED index 9449000cf..75acf2257 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,6 @@ # Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # Do not insert empty lines here, update check depends on it. + - feature: 98_TRAFFIC: v1.3.2, stroke styles, warnings reduced, bugfix - update: 98_DOIFtools: more precise regexp for INITIALIZED event because there is more than one initialisation event now - feature: 82_LGTV_WebOS: Version 0.6.0, pingPresence, Bugfixes diff --git a/fhem/FHEM/98_TRAFFIC.pm b/fhem/FHEM/98_TRAFFIC.pm index 17f919cb4..58ba1dc54 100644 --- a/fhem/FHEM/98_TRAFFIC.pm +++ b/fhem/FHEM/98_TRAFFIC.pm @@ -41,17 +41,10 @@ # 2017-04-21 reduced log entries if verbose is not set, fixed JSON error, Map available through FHEM-Web-toggle, and direct link # Map https, with APIKey, Traffic & customizable, new attributes GoogleMapsStyle,GoogleMapsSize,GoogleMapsLocation,GoogleMapsStroke,GoogleMapsDisableUI # 2017-04-21 added buttons to save current map settings, renamed attribute GoogleMapsLocation to GoogleMapsCenter +# 2017-04-22 v1.3.2 stroke supports weight and opacity, minor fixes # ############################################################################## - -#next: -# -# typo on update your map -# optional map zoom -# -# - package main; use strict; @@ -76,7 +69,7 @@ sub TRAFFIC_GetUpdate($); my %TRcmds = ( 'update' => 'noArg', ); -my $TRVersion = '1.3.1'; +my $TRVersion = '1.3.2'; sub TRAFFIC_Initialize($){ @@ -217,14 +210,27 @@ sub TRAFFIC_GetMap($@){ 'night' => '[{"elementType":"geometry","stylers":[{"color":"#242f3e"}]},{"elementType":"labels.text.fill","stylers":[{"color":"#746855"}]},{"elementType":"labels.text.stroke","stylers":[{"color":"#242f3e"}]},{"featureType":"administrative.locality","elementType":"labels.text.fill","stylers":[{"color":"#d59563"}]},{"featureType":"poi","elementType":"labels.text.fill","stylers":[{"color":"#d59563"}]},{"featureType":"poi.park","elementType":"geometry","stylers":[{"color":"#263c3f"}]},{"featureType":"poi.park","elementType":"labels.text.fill","stylers":[{"color":"#6b9a76"}]},{"featureType":"road","elementType":"geometry","stylers":[{"color":"#38414e"}]},{"featureType":"road","elementType":"geometry.stroke","stylers":[{"color":"#212a37"}]},{"featureType":"road","elementType":"labels.text.fill","stylers":[{"color":"#9ca5b3"}]},{"featureType":"road.highway","elementType":"geometry","stylers":[{"color":"#746855"}]},{"featureType":"road.highway","elementType":"geometry.stroke","stylers":[{"color":"#1f2835"}]},{"featureType":"road.highway","elementType":"labels.text.fill","stylers":[{"color":"#f3d19c"}]},{"featureType":"transit","elementType":"geometry","stylers":[{"color":"#2f3948"}]},{"featureType":"transit.station","elementType":"labels.text.fill","stylers":[{"color":"#d59563"}]},{"featureType":"water","elementType":"geometry","stylers":[{"color":"#17263c"}]},{"featureType":"water","elementType":"labels.text.fill","stylers":[{"color":"#515c6d"}]},{"featureType":"water","elementType":"labels.text.stroke","stylers":[{"color":"#17263c"}]}]', ); my $selectedGoogleMapsStyle = $GoogleMapsStyles{ AttrVal($name, "GoogleMapsStyle", 'default' )}; + if(!$selectedGoogleMapsStyle){$selectedGoogleMapsStyle = $GoogleMapsStyles{'default'}}; #catch attribute mistake here # load map scale and zoom from attr, override if empty/na my ( $GoogleMapsWidth, $GoogleMapsHeight ) = AttrVal($name, "GoogleMapsSize", '800,600') =~ m/(\d+),(\d+)/; my ( $GoogleMapsZoom ) = AttrVal($name, "GoogleMapsZoom", '10'); - my ( $GoogleMapsStroke1, $GoogleMapsStroke2 ) = AttrVal($name, "GoogleMapsStroke", '#4cde44,#FF0000') =~ m/(#[a-zA-z0-9]+),(#[a-zA-z0-9]+)/; + my ( $GoogleMapsStroke1Color, $GoogleMapsStroke1Weight, $GoogleMapsStroke1Opacity, $GoogleMapsStroke2Color, $GoogleMapsStroke2Weight, $GoogleMapsStroke2Opacity ) = AttrVal($name, "GoogleMapsStroke", '#4cde44,6,100,#FF0000,1,100') =~ m/^(#[a-zA-z0-9]+),?(\d*),?(\d*),?(#[a-zA-z0-9]+)?,?(\d*),?(\d*)/; - my $GoogleMapsDisableUI; + # catch incomplete configuration here and put in defaults + $GoogleMapsStroke1Color = '#4cde44' if !$GoogleMapsStroke1Color; + $GoogleMapsStroke1Weight = '6' if !$GoogleMapsStroke1Weight; + $GoogleMapsStroke1Opacity = '100' if !$GoogleMapsStroke1Opacity; + $GoogleMapsStroke2Color = '#FF0000' if !$GoogleMapsStroke2Color; + $GoogleMapsStroke2Weight = '1' if !$GoogleMapsStroke2Weight; + $GoogleMapsStroke2Opacity = '100' if !$GoogleMapsStroke2Opacity; + + # make percent value to 50 to 0.5 etc + $GoogleMapsStroke1Opacity = ($GoogleMapsStroke1Opacity / 100); + $GoogleMapsStroke2Opacity = ($GoogleMapsStroke2Opacity / 100); + + my $GoogleMapsDisableUI = ''; $GoogleMapsDisableUI = "disableDefaultUI: true," if AttrVal($name, "GoogleMapsDisableUI", 0) eq 1; Log3 $hash, 4, "TRAFFIC: ($name) drawing map in style ".AttrVal($name, "GoogleMapsStyle", 'default' )." in $GoogleMapsWidth x $GoogleMapsHeight px"; @@ -232,7 +238,7 @@ sub TRAFFIC_GetMap($@){ my $map; $map .= '