I create a virtual switch on/off (persistent)

In order to be able to tell my automations or scripts whether or not I allowed automatic watering, I wanted to create a ‘virtual’ switch, which has no link with any entity (i.e. not a template) and which keeps its state when the (persistent) Home Assistant is relaunched.

I create an input _boolean

Option 1: By configuration.yaml

In my _yaml configuration file, I will add my virtual switch

input_boolean: _automatic watering: #input_boolean.arrosage_automatic name: Authorized watering icon: mdi:sprinkler-variant

Option 2: Through the graphical interface

I go to Settings / Devices and Services / Inputs / Create Input / Switch 

I'll customize his icon

This is done in the customized.yaml file to be declared in the configuration.yaml file

In this customized.yaml file I add these lines

input_boolean.watering_automatic: templates: icon: > return (state === 'on')? 'mdi:sprinkler-variant' : 'mdi:water-off'; icon_color: > return (state === 'on')? 'green': 'rgb(54, 95, 140)';