Internet access - trigger once a day or based on a value

Hi there,

I’ve created a shell command to allow kids to reset the internet access for 1 hour.

I would like to allow the shell command once a day during the week. How can I do that ? I’ve been looking in but an example will be easier.

I’ve found this, this is the beginning :slight_smile:

  • condition: or
    • condition: time
      • mon
      • tue
      • wed
      • thu
      • fri
      • sat
    • condition: time
      • sun
        after: ‘08:00:00’
        before: ‘10:00:00’

Create separate input_boolean, set it to true when internet access has been used and use different automation to set back to false with time trigger.

Then use this input boolean as condition.

Excellent, thank you but how can I translate that into code?

In your configuration.yaml

    name: Internet access request available
    initial: true
    icon: mdi:access-point-network

If input boolean is true the access can be requested. If false then you can run some other actions.

In the automation:

  alias: Request for internet
    <your trigger>
    condition: state
    entity_id: input_boolean.internet_access_request_available
    state: 'on'
    - service: input_boolean.turn_off
        entity_id: input_boolean.internet_access_request_available
    - service: ....

Then additionally create the automation e.g. during night to switch input boolean back to on.

1 Like

Thank you for your reply, sorry to ask basic questions but I have only a few days experience in HA.
In fact, I have nothing in automation. Only a few entries in:


    quota_axel: ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i /config/.ssh/id_rsa [email protected] /usr/share/hassio/homeassistant/scripts/


  - service: shell_command.quota_axel
  alias: Quota AXEL

The result is this.


How can I write my automation.yaml ? What is the trigger ?

Yeah no problem!

Few things first.
Please format your code with three tick marks (```) around your code. Or the code formatter button </>. Makes it easier for others :slight_smile:

Basically everything you have goes into configuration.yaml, one way or another. Unless you make integration from the “integrations” page, use auto discovery etc.
The “automation:” with this rule goes also to configuration.yaml. You can look other configuration examples from the cookbook.
Check also the automation docs.

And back to your case. I’m not giving it handed :slight_smile:
You can reuse to code from the automation I gave as example. Create the input_boolean first.
Check with the docs how to use condition in a script.
So the script would be roughly:

  1. Check the condition if access has been used
  2. (service 1) turn off the input_boolean
  3. (service 2) call your shell command

Then create the automation to turn on the input boolean again. Use the time trigger.

In the end you would have one input_boolean, two scripts and one automation.

Thank you, I’ll try to find all the necessary information.