programmatically enabling/disabling skins ?

64 views
Skip to first unread message

Vince Skahan

unread,
Dec 10, 2021, 3:05:15 PM12/10/21
to weewx-development
I'm fiddling with automating rebuilding my setup and one of the customizations I make is to disable the default enabled skin(s) and to only enable my custom skins.  This requires me to hand-edit weewx.conf which is contrary to the idea of full automation (ansible or the like).

I know we have wee_config to switch drivers and do rudimentary editing of weewx.conf, so I was wondering if it's reasonable to try to extend that to enable/disable skins and/or set their HTML_ROOT parameters etc.

Not asking anybody to do any coding, just wondering if it would be of any interest...

Doug Jenkins

unread,
Dec 10, 2021, 4:50:54 PM12/10/21
to Vince Skahan, weewx-development
Vince:

I think there is a lot of value if we change the setup process to query the installed skins on a new weewx solution and have the user select it. The setup would proceed to make the correct skin entries in weewx.conf and enable that.

Let me know if you need some help with that.

DDJ



--
You received this message because you are subscribed to the Google Groups "weewx-development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to weewx-developm...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/weewx-development/8eef2433-51e8-48d3-923b-13df129c8a7dn%40googlegroups.com.

matthew wall

unread,
Dec 11, 2021, 7:52:06 AM12/11/21
to weewx-development
On Friday, December 10, 2021 at 3:05:15 PM UTC-5 vince...@gmail.com wrote:
I'm fiddling with automating rebuilding my setup and one of the customizations I make is to disable the default enabled skin(s) and to only enable my custom skins.  This requires me to hand-edit weewx.conf which is contrary to the idea of full automation (ansible or the like).

I know we have wee_config to switch drivers and do rudimentary editing of weewx.conf, so I was wondering if it's reasonable to try to extend that to enable/disable skins and/or set their HTML_ROOT parameters etc.

this seems like a reasonable set of options to add to wee_config.  perhaps something like this:

wee_config --enable-skin SKINNAME
wee_config --disable-skin SKINNAME

if the skin has been installed (i.e., there is a block in the weewx config file with the name SKINNAME), it enables the skin in that config file.

to do HTML_ROOT or other parameters that can be used with all skins we might need something more generic...

notice that this would not care about the actual weewx installation (e.g., contents of the skin directory) - it would only have to look at the specified config file.

(btw, wee_config should have the option '--config filename' so you can use this with any weewx config file, not just weewx.conf)

this is somewhat analogous to apache's a2x commands for enabling and disabling mods and confs.  that way ansible or salt or whatever does not have to worry about how a weewx config file is parsed/formatted.

m

Vince Skahan

unread,
Dec 11, 2021, 1:34:46 PM12/11/21
to weewx-development
Agree.   I was going to likely stop at listing the skins, enable/disable, and setting HTML_ROOT, but it would be nice to be able to edit anything under the skin's definition.  There's really no way to do that with ansible or the like since keywords are not unique in weewx.conf - man I wish we had anything other than configobj format, but so it goes....

Anyway, at this point I'm using wunderfixer as a simple example just to get my feet wet, but this does work for listing (not changing) the skins and some info therein quickly....

IMPORTANT - the attached script does NOT hide/delete/obfuscate any usernames/keys/passwords/etc/ in the config_dict for a skin, so don't post output please.  I'm just fiddling with things at this point to see what I can get at easily before seeing if I can add to it...

Quick example output for a few skins looks like the following.   Obviously any real utility would have very different formatting.

-----------------
SeasonsReport
-----------------
enable = false
HTML_ROOT = public_html/Standard

config_dict = {'skin': 'Seasons', 'enable': 'false', 'HTML_ROOT': 'public_html/Standard', 'Units': {'Groups': {'group_altitude': 'foot', 'group_speed2': 'mile_per_hour2', 'group_pressure': 'mbar', 'group_rain': 'inch', 'group_rainrate': 'inch_per_hour', 'group_temperature': 'degree_F', 'group_degree_day': 'degree_F_day', 'group_speed': 'mile_per_hour'}}}

-----------------
MQTT
-----------------
enable = true
HTML_ROOT not specified

config_dict = {'server_url': 'mqtt://localhost:1883', 'topic': 'weather', 'binding': ['archive', 'loop'], 'aggregation': 'aggregate', 'log_success': 'false', 'log_failure': 'true', 'enable': 'true'}

-----------------
FTP
-----------------
enable not specified
HTML_ROOT not specified

config_dict = {'skin': 'Ftp', 'secure_ftp': 'False', 'port': '21', 'passive': '1'}



printSkins.py

Vince Skahan

unread,
Dec 11, 2021, 5:24:05 PM12/11/21
to weewx-development
ok - hacked on wee_config to add a --list-skins option.

This look like it's in the ballpark for a reasonable output ?

  ------               ---------       -----------
  (SKIN)               (ENABLED)       (HTML_ROOT)
  ------               ---------       -----------
  Belchertown          true            public_html/belchertown
  FTP                  false           undefined
  MobileReport         false           public_html/mobile
  RSYNC                false           undefined
  SeasonsReport        true            undefined
  SmartphoneReport     false           public_html/smartphone
  StandardReport       false           undefined
  forecast             undefined       public_html/forecast
  lastrain             undefined       public_html/lastrain
  mem                  undefined       public_html/mem
  vds-bootstrap        undefined       public_html/bootstrap
  vds-local            undefined       undefined


Reply all
Reply to author
Forward
0 new messages