My plugin updates (#16806)

Co-authored-by: Bram Kragten <mail@bramkragten.nl>
This commit is contained in:
Franck Nijhof 2021-03-02 14:13:56 +01:00
parent 2dc57d429a
commit 1e419b6d8e
No known key found for this signature in database
GPG Key ID: D62583BA8AB11CA3
9 changed files with 61 additions and 31 deletions

View File

@ -173,6 +173,7 @@
"MJPEG", "MJPEG",
"MQTT", "MQTT",
"Mullvad", "Mullvad",
"My Home Assistant",
"MySensors", "MySensors",
"NAS", "NAS",
"NETGEAR", "NETGEAR",
@ -278,7 +279,6 @@
"XML", "XML",
"Yamaha MusicCast", "Yamaha MusicCast",
"Yamaha", "Yamaha",
"YAML",
"Yandex", "Yandex",
"Yeelight", "Yeelight",
"YouTube", "YouTube",
@ -302,7 +302,6 @@
["cancelled", "canceled"], ["cancelled", "canceled"],
["client ?side", "client-side"], ["client ?side", "client-side"],
["colour", "color"], ["colour", "color"],
["config\\b", "configuration"],
["DarkSky", "Dark Sky"], ["DarkSky", "Dark Sky"],
["docs\\b", "documentation"], ["docs\\b", "documentation"],
["e\\.g\\.", "e.g.,"], ["e\\.g\\.", "e.g.,"],

View File

@ -12,11 +12,11 @@ module Jekyll
else else
raise SyntaxError, <<~MSG raise SyntaxError, <<~MSG
Syntax error in tag 'my' while parsing the following options: Syntax error in tag 'my' while parsing the following options:
`
#{args} #{args}
Valid syntax: Valid syntax:
{% my <redirect> [title="Link name"] [badge] [icon[="icon-puzzle-piece"]] [addon="core_ssh"] [blueprint_url=""] [domain="hue"] %} {% my <redirect> [title="Link name"] [badge] [icon[="icon-puzzle-piece"]] [addon="core_ssh"] [blueprint_url="http://example.com/blueprint.yaml"] [domain="hue"] [service="light.turn_on"] %}
MSG MSG
end end
end end
@ -33,24 +33,39 @@ module Jekyll
query += [["addon", options[:addon]]] if options.include? :addon query += [["addon", options[:addon]]] if options.include? :addon
query += [["blueprint_url", options[:blueprint_url]]] if options.include? :blueprint_url query += [["blueprint_url", options[:blueprint_url]]] if options.include? :blueprint_url
query += [["domain", options[:domain]]] if options.include? :domain query += [["domain", options[:domain]]] if options.include? :domain
query += [["service", options[:service]]] if options.include? :service
unless query.empty? unless query.empty?
uri.query = URI.encode_www_form(query) uri.query = URI.encode_www_form(query)
end end
if options[:badge] if options[:badge]
title = options[:title] ? options[:title].gsub(/\ /, '_') : @redirect raise ArgumentError, "Badges cannot have custom titles" if options[:title]
"<a href='#{uri}' class='my badge' target='_blank'>"\ "<a href='#{uri}' class='my badge' target='_blank'>"\
"<img src='https://img.shields.io/badge/#{title}-my?style=for-the-badge&label=MY&logo=home-assistant&color=41BDF5&logoColor=white' />"\ "<img src='https://my.home-assistant.io/badges/#{@redirect}.svg' />"\
"</a>" "</a>"
else else
title = options[:title] ? options[:title] : @redirect.gsub(/_/, ' ').titlecase title = @redirect.gsub(/_/, ' ').titlecase
icon = "" icon = ""
if options[:title]
# Custom title
title = options[:title]
elsif @redirect == "developer_call_service"
# Developer service call
title = "Call Service"
title = "`#{options[:service]}`" if options.include? :service
elsif DEFAULT_TITLES.include?(@redirect)
# Lookup defaults
title = DEFAULT_TITLES[@redirect]
end
if options[:icon] if options[:icon]
raise ArgumentError, "No default icon for redirect #{@redirect}" \ raise ArgumentError, "No default icon for redirect #{@redirect}" \
if !!options[:icon] == options[:icon] and ! DEFAULT_ICONS.include?(@redirect) if !!options[:icon] == options[:icon] and ! DEFAULT_ICONS.include?(@redirect)
icon = !!options[:icon] == options[:icon] ? DEFAULT_ICONS[@redirect] : @options[:icon] icon = !!options[:icon] == options[:icon] ? DEFAULT_ICONS[@redirect] : @options[:icon]
icon = "<i class='#{icon}' /> " icon = "<i class='#{icon}' /> "
end end
"#{icon}<a href='#{uri}' class='my' target='_blank'>#{title}</a>" "#{icon}<a href='#{uri}' class='my' target='_blank'>#{title}</a>"
end end
end end
@ -60,11 +75,32 @@ module Jekyll
SYNTAX = %r!^([a-z_]+)((\s+\w+(=([\w\.]+?|".+?"))?)*)$!.freeze SYNTAX = %r!^([a-z_]+)((\s+\w+(=([\w\.]+?|".+?"))?)*)$!.freeze
OPTIONS_REGEX = %r!(?:\w="[^"]*"|\w=[\w\.]+|\w)+!.freeze OPTIONS_REGEX = %r!(?:\w="[^"]*"|\w=[\w\.]+|\w)+!.freeze
# Default icons when used in in-line text
DEFAULT_ICONS = { DEFAULT_ICONS = {
"config_flow_start" => "icon-plus-sign", "config_flow_start" => "icon-plus-sign",
"config" => "icon-cog",
"integrations" => "icon-puzzle-piece", "integrations" => "icon-puzzle-piece",
} }
# Default title used for in-line text
DEFAULT_TITLES = {
"blueprint_import" => "Import Blueprint",
"cloud" => "Home Assistant Cloud",
"config_flow_start" => "Add Integration",
"config_mqtt" => "MQTT Configuration",
"config_zha" => "ZHA Configuration",
"config_zwave_js" => "Z-Wave JS Configuration",
"config" => "Configuration",
"developer_events" => "Events",
"developer_services" => "Services",
"developer_states" => "States",
"developer_template" => "Templates",
"general" => "General Settings",
"info" => "Information",
"supervisor_info" => "Supervisor Information",
"supervisor_snapshots" => "Snapshots",
}
def parse_options(input, context) def parse_options(input, context)
options = {} options = {}
return options if input.empty? return options if input.empty?

View File

@ -676,6 +676,5 @@ code {
a.my { a.my {
img { img {
border: 0px; border: 0px;
border-radius: 3px;
} }
} }

View File

@ -5,7 +5,7 @@ description: "How to use the various automation services."
The automation integration has services to control automations, like turning automations on and off. This can be useful if you want to disable an automation from another automation. The automation integration has services to control automations, like turning automations on and off. This can be useful if you want to disable an automation from another automation.
## Service `automation.turn_on` ## Service {% my developer_call_service service="automation.turn_on" %}
This service enables the automation's triggers. This service enables the automation's triggers.
@ -13,7 +13,7 @@ Service data attribute | Optional | Description
-|-|- -|-|-
`entity_id` | no | Entity ID of automation to turn on. Can be a list. `none` or `all` are also accepted. `entity_id` | no | Entity ID of automation to turn on. Can be a list. `none` or `all` are also accepted.
## Service `automation.turn_off` ## Service {% my developer_call_service service="automation.turn_off" %}
This service disables the automation's triggers, and optionally stops any currently active actions. This service disables the automation's triggers, and optionally stops any currently active actions.
@ -22,7 +22,7 @@ Service data attribute | Optional | Description
`entity_id` | no | Entity ID of automation to turn on. Can be a list. `none` or `all` are also accepted. `entity_id` | no | Entity ID of automation to turn on. Can be a list. `none` or `all` are also accepted.
`stop_actions` | yes | Stop any currently active actions (defaults to true). `stop_actions` | yes | Stop any currently active actions (defaults to true).
## Service `automation.toggle` ## Service {% my developer_call_service service="automation.toggle" %}
This service enables the automation's triggers if they were disabled, or disables the automation's triggers, and stops any currently active actions, if the triggers were enabled. This service enables the automation's triggers if they were disabled, or disables the automation's triggers, and stops any currently active actions, if the triggers were enabled.
@ -30,7 +30,7 @@ Service data attribute | Optional | Description
-|-|- -|-|-
`entity_id` | no | Entity ID of automation to turn on. Can be a list. `none` or `all` are also accepted. `entity_id` | no | Entity ID of automation to turn on. Can be a list. `none` or `all` are also accepted.
## Service `automation.trigger` ## Service {% my developer_call_service service="automation.trigger" %}
This service will trigger the action of an automation. By default it bypasses any conditions, though that can be changed via the `skip_condition` attribute. This service will trigger the action of an automation. By default it bypasses any conditions, though that can be changed via the `skip_condition` attribute.
@ -39,7 +39,7 @@ Service data attribute | Optional | Description
`entity_id` | no | Entity ID of automation to trigger. Can be a list. `none` or `all` are also accepted. `entity_id` | no | Entity ID of automation to trigger. Can be a list. `none` or `all` are also accepted.
`skip_condition` | yes | Whether or not the condition will be skipped (defaults to true). `skip_condition` | yes | Whether or not the condition will be skipped (defaults to true).
## Service `automation.reload` ## Service {% my developer_call_service service="automation.reload" %}
_This service is only required if you create/edit automations in YAML. Automations via the UI do this automatically._ _This service is only required if you create/edit automations in YAML. Automations via the UI do this automatically._

View File

@ -7,7 +7,7 @@ Automations support [templating](/docs/configuration/templating/) in the same wa
<div class='note'> <div class='note'>
Be aware that if you reference a `trigger` state object in templates of an automation' `action` or `condition` sections, attempting to test that automation by calling the `automation.trigger` service or by clicking EXECUTE in the More Info box for the automation will not work. This is because the trigger state object doesn't exist in those contexts. One way to test automations like these is to manually check that the templates work as expected by pasting them in Developer Tools > Template together with your trigger's definition like: Be aware that if you reference a `trigger` state object in templates of an automation' `action` or `condition` sections, attempting to test that automation by calling the `automation.trigger` service or by clicking EXECUTE in the More Info box for the automation will not work. This is because the trigger state object doesn't exist in those contexts. One way to test automations like these is to manually check that the templates work as expected by pasting them in {% my developer_template title="Developer Tools > Template" %} together with your trigger's definition like:
{%raw%} {%raw%}

View File

@ -13,11 +13,11 @@ Quick links:
Automations based on a blueprint only need to be configured to be used. What needs to be configured differs on each blueprint. Automations based on a blueprint only need to be configured to be used. What needs to be configured differs on each blueprint.
To create your first automation based on a blueprint, go to **Configuration** and then **Blueprints**. Find the blueprint that you want to use and click on "Create Automation". To create your first automation based on a blueprint, go to **{% my config %}** and then **{% my blueprints %}**. Find the blueprint that you want to use and click on "Create Automation".
This will open the automation editor with the blueprint selected. Give it a name and configure the blueprint and click on the blue button "Save Automation" in the bottom right. This will open the automation editor with the blueprint selected. Give it a name and configure the blueprint and click on the blue button "Save Automation" in the bottom right.
Done! If you want to revisit the configuration values, you can find it by going to **Configuration** and then **Automations**. Done! If you want to revisit the configuration values, you can find it by going to **{% my config %}** and then **{% my automations %}**.
## Importing blueprints ## Importing blueprints
@ -29,7 +29,7 @@ To do this, first [find a blueprint you want to import][blueprint-forums]. If yo
https://github.com/home-assistant/core/blob/dev/homeassistant/components/automation/blueprints/motion_light.yaml https://github.com/home-assistant/core/blob/dev/homeassistant/components/automation/blueprints/motion_light.yaml
``` ```
Go to **Configuration** and then **Blueprints**. Click on the blue "Import Blueprint" button in the bottom right. Go to **{% my config %}** and then **{% my blueprints %}**. Click on the blue "{% my blueprint_import blueprint="https://github.com/home-assistant/core/blob/master/homeassistant/components/automation/blueprints/motion_light.yaml" %} button in the bottom right.
A new dialog will pop-up asking you for the URL. Enter the URL and click on "preview blueprint". A new dialog will pop-up asking you for the URL. Enter the URL and click on "preview blueprint".

View File

@ -8,7 +8,7 @@
{%- endif -%} {%- endif -%}
{%- if page.ha_config_flow and page.ha_domain -%} {%- if page.ha_config_flow and page.ha_domain -%}
{% my config_flow_start badge title="Add Integration" domain=page.ha_domain %} {% my config_flow_start badge domain=page.ha_domain %}
{%- endif -%} {%- endif -%}
</div> </div>

View File

@ -14,7 +14,7 @@ A partial snapshot consists of any number of the above default directories and i
### Making a Snapshot from the UI ### Making a Snapshot from the UI
1. Go to Supervisor > Snapshots in the UI 1. Go to {% my supervisor_snapshots title="Supervisor > Snapshots" %} in the UI
2. Provide a name for the snapshot. 2. Provide a name for the snapshot.
3. Choose full or partial. 3. Choose full or partial.
4. Choose to password protect or not. Password protected snapshots cannot easily be browsed outside of Home Assistant OS 4. Choose to password protect or not. Password protected snapshots cannot easily be browsed outside of Home Assistant OS
@ -53,11 +53,7 @@ Use `ha help` to see more info.
You often need a snapshot in case your system has crashed. If you only store them on the crashed device, you won't be able to access it easily. We recommend that you manually copy them from `/backup` to another machine on occasion. Or even better, create an automation to handle that, or make use of one of the following add-ons: You often need a snapshot in case your system has crashed. If you only store them on the crashed device, you won't be able to access it easily. We recommend that you manually copy them from `/backup` to another machine on occasion. Or even better, create an automation to handle that, or make use of one of the following add-ons:
- [Google Drive Backup](https://github.com/sabeechen/hassio-google-drive-backup) - [Google Drive Backup](https://github.com/sabeechen/hassio-google-drive-backup)
- [Dropbox Sync](https://github.com/danielwelch/hassio-dropbox-sync) - [Dropbox Sync](https://github.com/danielwelch/hassio-dropbox-sync)
- [Nextcloud Backup](https://github.com/Sebclem/hassio-nextcloud-backup) - [Nextcloud Backup](https://github.com/Sebclem/hassio-nextcloud-backup)
- [Samba backup](https://github.com/thomasmauerer/hassio-addons/tree/master/samba-backup) - [Samba backup](https://github.com/thomasmauerer/hassio-addons/tree/master/samba-backup)
- [Remote Backup (uses scp)](https://github.com/overkill32/hassio-remote-backup) - [Remote Backup (uses scp)](https://github.com/overkill32/hassio-remote-backup)

View File

@ -6,7 +6,7 @@ Adding {{ name }} to your Home Assistant instance can be done via the user
interface, by taking the following steps: interface, by taking the following steps:
- Browse to your Home Assistant instance. - Browse to your Home Assistant instance.
- In the sidebar click on <i class="icon-cog"/> _**Configuration**_. - In the sidebar click on _**{% my config icon %}**_.
- From the configuration menu select: _**{% my integrations icon %}**_. - From the configuration menu select: _**{% my integrations icon %}**_.
{% if include.discovery or page.ha_dhcp or page.ha_homekit or page.ha_ssdp or page.ha_zeroconf %} {% if include.discovery or page.ha_dhcp or page.ha_homekit or page.ha_ssdp or page.ha_zeroconf %}
@ -20,7 +20,7 @@ manual integration entry:
{% endif %} {% endif %}
- In the bottom right, click on the - In the bottom right, click on the
_**{% my config_flow_start icon title="Add Integration" domain=page.ha_domain %}**_ button. _**{% my config_flow_start icon domain=page.ha_domain %}**_ button.
- From the list, search and select _**"{{ name }}"**_. - From the list, search and select _**"{{ name }}"**_.
- Follow the instruction on screen to complete the set up. - Follow the instruction on screen to complete the set up.