I'm New to Hass.io, need assistane

I am new to Hass.io, and have managed to install it on my raspberry pi 3.

The overview page has nothing on it yet, except 1 switch which I setup in the configuration file.

#Switches
switch:
  - platform: rpi_gpio
    ports:
      21: Switch1

I don’t have a relay or led attached to GPIO21 as yet, so have not been able to test if it work, I suspect it does.

I now would like to create a timer for the same GPIO pin

I would like to have it come on at a specific time and then off at a specific time, I understand it will be 2 time triggers. One for switching on and One for switchin off.

The problem that I am having is that there is very little info out there that I have found (May be searching incorrect wording) that deals with GPIO’s

I am also not familiar with the hass.io configuration file as yet, to be able to understand from examples on the site.

If someone could help with the config of the above GPIO21 to be switched on at time of 18:00, I am sure I would be able to do the off time myself by learning from that code.

TIA

I can confirm that my relays are working, added the following in my config.

#Switches
switch:
  platform: rpi_gpio
  ports:
    16: GPIO16
    20: GPIO20
  invert_logic: true

There is 2 things that I would like to do now.

Firstly I would like to create a timer that triggers a GPIO to be on at a certain time.
Then secondly instead of these two GPIO’s being displayed as switches I would like them to be listed as taps.

How would I achieve both of these scenarios?

TIA

Hi there. You have to make a automation based on time to trigger the on/off at a specific time. See https://home-assistant.io/docs/automation/trigger/ for more info. I am a bit uncertain about the taps, but play around with customize to see if you find anything you like: https://home-assistant.io/docs/configuration/customizing-devices/

Cheers

Thank you for your reply, I have gone through the documentation, but it does not make it clear, even in the examples it’s not clear.

I understand that I will need to have something like this:

automation:
  trigger: time
    time: xx:xx

The problem I am having is that the documentation does not really cover time based on and time based off, along with the GPIO pins, as somewhere I would need to specify what must be switched on and off

It’s for this reason I am looking for an example config for a GPIO pin, from there I am sure I will pick up what needs to be done.

Also where does one find the valid entity id’s to specify which device you want switched.

None of the examples for Automation have time based event, that triggers a switch or device from what I can see, maybe missing it, but so far I have not found anything that helps in me setting up a time based switch event on a GPIO pin

Hi techbw,

a simple hardcoded time based automation could look like this (not sure on the entity_id of gpio16):

automation:
  trigger:
    platform: time
    at: '15:32:00'
  action:
    service: switch.turn_on
    entity_id: switch.?gpio16?

You can find all available entity_ids in the “Developer tools” - “States” inside the Home Assistant UI

image

@eXtatic

Thank you this will be a world of help.

I did not see entity id in my States for the two switches only friendly names, but from what I gather the name on the left

switch.gpio16 off friendly_name: GPIO16
switch.gpio20 off friendly_name: GPIO20

switch.gpioxx is the entity id.

Is this assumption correct?

That is correct!
Basically if you define entities by a friendly name only, you can expect HA to create the entity id by making the friendly name lower case and replacing blanks by underscores.

automation:
  trigger:
    platform: time
    at: '10:50:00'
  action:
    service: switch.turn_on
    entity_id: switch.gpio16

When validating code it says it’s not valid when pasting into automation.yaml file

it seams that there are - supposed to be in that code just not sure where that is, so just a formatting issue by the looks of it

Hey, is this the only automation you have?

EDIT:
Seems like the alias is missing

  automation:
    - alias: "Turn on GPIO 16"
      trigger:
        platform: time
        at: '10:50:00'
      action:
        service: switch.turn_on
        entity_id: switch.gpio16

At the moment yes, it’s just a pi connected to a relay, no additional hardware as yet, busy learning this setup and so on.

Before I implement it any further I want to have a better understanding on the automation setup on hass.io, currently running webiopi and custom scripts run from cron to do the job and has been working for 2 years, but would like to add voice commands in the future so learning hass IO to do that

The interface is nice, but the automation side of things seems very difficult
My code bellow to switch on at a time failed but the code validated

I did manage to get all switches on using the builder under automation, but can’t get it to trigger just GPIO16

- automation:
  - alias: 'GPIO16 Timer switch on at xx:xx'
      trigger:
        platform: time
        entity_id: switch.gpio16
        at '11:59:00'
      action:
        service: switch.turn_on

I changed the code to this

- automation:
  - alias: 'GPIO16 Timer switch on at xx:xx'
      trigger:
        platform: time
        at: '12:08:00'
      action:
        service: switch.turn_on
        entity_id: switch.gpio16

What that did was fix the colon on the line with at, and moved entity_id to action, this now triggers both gpio16 and gpio20

Why I don’t know

Hi. Try using the homeassistant service instead.

  - alias: 'GPIO16 Timer switch on at xx:xx'
      trigger:
        platform: time
        at: '12:08:00'
      action:
        service: homeassistant.turn_on
        entity_id: switch.gpio16

Hey, was the automation triggered at all?

You can check it again in the “States” section:

That seemed to make it work, when manually triggered, will test timer and get back to you.

Thank you.

[Edit]

It worked on timer as meant to be …Thank you again!