diff --git a/README.md b/README.md index bac5568..8f0672f 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,8 @@ docker create \ --restart unless-stopped \ rmountjoy/dashmachine:latest ``` +### Synology +Check out this awesome guide: https://nashosted.com/manage-your-self-hosted-applications-using-dashmachine/ ### Python Instructions are for linux. ``` diff --git a/dashmachine/main/read_config.py b/dashmachine/main/read_config.py index e958a20..15b203b 100644 --- a/dashmachine/main/read_config.py +++ b/dashmachine/main/read_config.py @@ -191,14 +191,11 @@ def read_config(): db.session.merge(tag_db) db.session.commit() else: - if Tags.query.first(): - app.tags = "Untagged" - if not Tags.query.filter_by(name="Untagged").first(): - tag_db = Tags(name="Untagged") - db.session.add(tag_db) - db.session.commit() - else: - app.tags = None + app.tags = "Untagged" + if not Tags.query.filter_by(name="Untagged").first(): + tag_db = Tags(name="Untagged") + db.session.add(tag_db) + db.session.commit() db.session.add(app) db.session.commit() diff --git a/dashmachine/platform/transmission.py b/dashmachine/platform/transmission.py index 00dc05d..3c2038e 100644 --- a/dashmachine/platform/transmission.py +++ b/dashmachine/platform/transmission.py @@ -19,8 +19,8 @@ value_template = {{ value_template }} | platform | Yes | Name of the platform. | transmission | | host | Yes | Host of Transmission Web UI | host | | port | Yes | Port of Transmission Web UI | port | -| user | No | Username for Transmission Web UI | username | -| password | No | Password for Transmission Web UI | password | +| user | Yes | Username for Transmission Web UI | username | +| password | Yes | Password for Transmission Web UI | password | | value_template | Yes | Jinja template for how the returned data from API is displayed. | jinja template |
diff --git a/dashmachine/platform/weather.py b/dashmachine/platform/weather.py new file mode 100644 index 0000000..cd2c6d3 --- /dev/null +++ b/dashmachine/platform/weather.py @@ -0,0 +1,130 @@ +""" + +##### Weather +Weather is a great example of how you can populate a custom card on the dash. This plugin creates a custom card with weather data from [metaweather.com](https://www.metaweather.com) +```ini +[variable_name] +platform = weather +woeid = 2514815 +temp_unit = c +wind_speed_unit = kph +air_pressure_unit = mbar +visibility_unit = km +``` +> **Returns:** HTML for custom card + +| Variable | Required | Description | Options | +|-----------------|----------|--------------------------------------------------------------------------------------------------------------------------------------------|-------------------| +| [variable_name] | Yes | Name for the data source. | [variable_name] | +| platform | Yes | Name of the platform. | weather | +| woeid | Yes | woeid of location to use. Go here to get (replace lat and long): https://www.metaweather.com/api/location/search/?lattlong=50.068,-5.316 | url | +| temp_unit | No | The unit to be used for temperature | c,f | +| wind_speed_unit | No | The unit to be used for wind speed | kph,mph | +| air_pressure_unit | No | The unit to be used for air pressure | mbar, inHg | +| visibility_unit | No | The unit to be used for visibility | km,mi | + +> **Working example:** +>```ini +>[variable_name] +>platform = weather +>woeid = 2514815 +> +>[custom_card_name] +>type = custom +>data_sources = variable_name +>``` + +""" + +import requests +from flask import render_template_string + + +class Platform: + def __init__(self, *args, **kwargs): + # parse the user's options from the config entries + for key, value in kwargs.items(): + self.__dict__[key] = value + + # set defaults for omitted options + if not hasattr(self, "woeid"): + self.woeid = 2514815 + if not hasattr(self, "temp_unit"): + self.temp_unit = "c" + if not hasattr(self, "wind_speed_unit"): + self.wind_speed_unit = "kph" + if not hasattr(self, "air_pressure_unit"): + self.air_pressure_unit = "x" + if not hasattr(self, "visibility_unit"): + self.visibility_unit = "km" + + self.html_template = """ +
+
+ {{ value.consolidated_weather[0].the_temp|round(1, 'floor') }}° +
+
+ +
+
+
+
{{ value.parent.title }}
+
+
+ keyboard_arrow_down +
+
+
+
+
Currently: {{ value.consolidated_weather[0].weather_state_name }}
+
Min: {{ value.consolidated_weather[0].min_temp|round(1, 'floor') }}° Max: {{ value.consolidated_weather[0].max_temp|round(1, 'floor') }}°
+
Wind: {{ value.consolidated_weather[0].wind_direction_compass }} at {{ value.consolidated_weather[0].wind_speed|round(1, 'floor') }} {{ wind_speed_unit }}
+
Humidity: {{ value.consolidated_weather[0].humidity }}%
+
Air Pressure: {{ value.consolidated_weather[0].air_pressure|round(1, 'floor') }}
+
Visibility: {{ value.consolidated_weather[0].visibility|round(1, 'floor') }}
+
Predictability: {{ value.consolidated_weather[0].predictability }}%
+
+
+
+ """ + + self.error_template = """ +
+
+ Check your config. This error was returned: {{ error }} +
+
+ """ + + def process(self): + try: + value = requests.get( + f"https://www.metaweather.com/api/location/{self.woeid}" + ).json() + except Exception as error: + return render_template_string(self.error_template, error=error) + + if self.temp_unit.lower() == "f": + value["consolidated_weather"][0]["the_temp"] = ( + value["consolidated_weather"][0]["the_temp"] * 1.8 + ) + 32 + value["consolidated_weather"][0]["min_temp"] = ( + value["consolidated_weather"][0]["min_temp"] * 1.8 + ) + 32 + value["consolidated_weather"][0]["max_temp"] = ( + value["consolidated_weather"][0]["max_temp"] * 1.8 + ) + 32 + + if self.wind_speed_unit.lower() == "mph": + value["consolidated_weather"][0]["wind_speed"] = ( + value["consolidated_weather"][0]["wind_speed"] * 1.609 + ) + + if self.air_pressure_unit.lower() == "inhg": + value["consolidated_weather"][0]["air_pressure"] = ( + value["consolidated_weather"][0]["air_pressure"] / 33.864 + ) + + return render_template_string( + self.html_template, value=value, wind_speed_unit=self.wind_speed_unit + ) diff --git a/dashmachine/static/images/apps/cloudcmd.png b/dashmachine/static/images/apps/cloudcmd.png index 7891a81..22a22df 100644 Binary files a/dashmachine/static/images/apps/cloudcmd.png and b/dashmachine/static/images/apps/cloudcmd.png differ diff --git a/dashmachine/static/images/apps/emby.png b/dashmachine/static/images/apps/emby.png index 2c3c1af..538b2d1 100644 Binary files a/dashmachine/static/images/apps/emby.png and b/dashmachine/static/images/apps/emby.png differ diff --git a/dashmachine/static/images/apps/filerun.png b/dashmachine/static/images/apps/filerun.png index 747d2f0..75374c5 100644 Binary files a/dashmachine/static/images/apps/filerun.png and b/dashmachine/static/images/apps/filerun.png differ diff --git a/dashmachine/static/images/apps/glances.png b/dashmachine/static/images/apps/glances.png index 9ebd7a1..032318e 100644 Binary files a/dashmachine/static/images/apps/glances.png and b/dashmachine/static/images/apps/glances.png differ diff --git a/dashmachine/static/images/apps/grafana.png b/dashmachine/static/images/apps/grafana.png index e9e0b02..4587622 100644 Binary files a/dashmachine/static/images/apps/grafana.png and b/dashmachine/static/images/apps/grafana.png differ diff --git a/dashmachine/static/images/apps/guacamole.png b/dashmachine/static/images/apps/guacamole.png index 28bcae7..4d67016 100644 Binary files a/dashmachine/static/images/apps/guacamole.png and b/dashmachine/static/images/apps/guacamole.png differ diff --git a/dashmachine/static/images/apps/handbrake.png b/dashmachine/static/images/apps/handbrake.png index 4e687d7..ccd272a 100644 Binary files a/dashmachine/static/images/apps/handbrake.png and b/dashmachine/static/images/apps/handbrake.png differ diff --git a/dashmachine/static/images/apps/ombi.png b/dashmachine/static/images/apps/ombi.png index ee09f64..6b8df43 100644 Binary files a/dashmachine/static/images/apps/ombi.png and b/dashmachine/static/images/apps/ombi.png differ diff --git a/dashmachine/static/images/apps/opnsense.png b/dashmachine/static/images/apps/opnsense.png index a818049..b237eb8 100644 Binary files a/dashmachine/static/images/apps/opnsense.png and b/dashmachine/static/images/apps/opnsense.png differ diff --git a/dashmachine/static/images/apps/sonarr.png b/dashmachine/static/images/apps/sonarr.png index ea5531d..7cc9206 100644 Binary files a/dashmachine/static/images/apps/sonarr.png and b/dashmachine/static/images/apps/sonarr.png differ diff --git a/dashmachine/static/images/apps/statping.png b/dashmachine/static/images/apps/statping.png index 507b79f..1c8391d 100644 Binary files a/dashmachine/static/images/apps/statping.png and b/dashmachine/static/images/apps/statping.png differ diff --git a/dashmachine/static/images/apps/transmission.png b/dashmachine/static/images/apps/transmission.png index cebae45..f47d6a6 100644 Binary files a/dashmachine/static/images/apps/transmission.png and b/dashmachine/static/images/apps/transmission.png differ diff --git a/dashmachine/templates/main/app-view.html b/dashmachine/templates/main/app-view.html index 75f6fb0..5de8cf6 100644 --- a/dashmachine/templates/main/app-view.html +++ b/dashmachine/templates/main/app-view.html @@ -18,4 +18,4 @@ {% block page_lvl_js %} -{% endblock page_lvl_js %} +{% endblock page_lvl_js %} \ No newline at end of file diff --git a/dashmachine/templates/main/home.html b/dashmachine/templates/main/home.html index 48b12aa..6b7a383 100644 --- a/dashmachine/templates/main/home.html +++ b/dashmachine/templates/main/home.html @@ -28,10 +28,12 @@ search - unfold_less + {% if tags_form.tags.choices|count > 2 %} + unfold_less + {% endif %} - {% if tags_form.tags.choices|count > 1 %} + {% if tags_form.tags.choices|count > 2 %}
{{ tags_form.tags(id='tags-select') }}
diff --git a/dashmachine/version.py b/dashmachine/version.py index 44a1120..0b9070f 100755 --- a/dashmachine/version.py +++ b/dashmachine/version.py @@ -1,2 +1,2 @@ version = "v0.5" -revision_number = "3" +revision_number = "4"