#Snapshot of Cam every 5 min

1 messages · Page 1 of 1 (latest)

bold totem
#

Cam: ESP-Cam
Idea: Switch that turns on and off an automation which takes a snapshot every 5 min
Use-case: surveillance of my 3d Printer

I don‘t understand how I can make the trigger to be a switch that keeps the automation running while it‘s on, I might try with NodeRED.

faint oasis
#

No need. You can turn automation entities on and off.

#

If you want to overcomplicate it, you could use an input boolean as automation condition or create a template switch.

bold totem
#

Oh what

faint oasis
#
action: automation.turn_off
target:
  entity_id: automation.demo_automation
data:
  stop_actions: true

There are also automation.turn_on and automation.toggle actions.

#

And in the UI you can toggle them directly.

bold totem
#

I cannot comprehend

#

This is my first HA automation

faint oasis
#
type: tile
entity: automation.demo_automation
features_position: bottom
vertical: false
bold totem
#

I haven‘t had enough devices so far to make a meaningful automation

faint oasis
#

You asked about a way to turn an automation on and off. You can do that directly with a card in the UI (using the automation entities) or you use an action call (in another automation for example).

bold totem
#

I‘m not sure if I have it

#

Where should I save the snapshot, I thought /var/tmp?

#

Should I add something in the triggers?

faint oasis
#

You would need a time pattern triggger with /5in the minutes field to trigger every 5 minutes.

#

Well... whenever the minutes are dividable by 5.

bold totem
#

ahh

#

omg

#

makes sense this is a thing

faint oasis
#

The last delay would be unnecessary.

bold totem
#

Like this right?

faint oasis
#

Yes. But in this case it would create a snapshot whenever the minutes on the clock are dividable by 5. Not every 5 minutes after the automation has been started. Not sure if that is critical for you. And I would add a delay of a few seconds after the snapshot. Just to be sure the light doesn't turn off too early.

bold totem
#

Ich muss leider los, danke für deine Hilfe<3

#

Ill take that into account

faint oasis
#

You are welcome. But please keep it in English. shksD

bold totem
#

Alright, it seems to work now, it‘s not critical that its every minute divisible by 5. I‘ll try to add a run when it starts like that ig:

#

nah that just keeps triggering itself

faint oasis
#

Yes, it runs until it is turned off.

bold totem
#

actuallyI wasnt finished

#

Everything works, except it doesnt work

#

Its not writing a file

#

Will have to look into the take snapshot funvtion

bold totem
#

WHat is a good directory for this to write in, and as what user are the files written/or may it be an AppArmor thing /var/tmp has 777 directory permissions

faint oasis
#

It has to be accessible by the HA container and it has to be in the allowed list.

The path part of filename must be an entry in the allowlist_external_dirs in your homeassistant: section of your configuration.yaml file.

bold totem
#

It doesn‘t work, idk why, I don‘t get any logs anymore, but I tried in /tmp /var/tmp and /media

faint oasis
#

If you choose the /tmp directory, it will be in the directory of the HA container, not the host OS, the Studio Code container or the SSH container. So you don't see it in the usual tools.

bold totem
#

Ahh

#

Home assistant runs in a container on hassos?

faint oasis
#

/mediashould work

bold totem
#

Thats an important thing to know

#

I wasnt sure what u were talking about because I have Home Assistant OS in a VM

#

But

#

Also

#

Im an Idiot

#

I turned the psu off for the cam xD

#

only the /media dir is a shared directory?

faint oasis
#

HAOS is the host OS. It runs several containers, like HA. And addons like SSH/Terminal or Studio Code are additional containers. They seem to show the host OS, but that's just true for some selected resources.

bold totem
#

Makes sense, thank you for the explanation

faint oasis
#

There are some more. Like /config, /addons, addon_configs, /ssland so on.

#

Shared directories can be accessed by other addons.

bold totem
#

For a long time I thought to myself why aren‘t addons supported in container, because you can make containers in lxc I know but now all makes sense more or less, Its a whole nother shell around hassio core

#

Btw it works now yay

faint oasis
#

In some usecases, using /config/www is the better choice. Everything in that directory can be browsed directly via a http://homeassistant.local:8123/local/... address. However it is not password protected.

bold totem
#

Ill prob use that dir if I make a status screen thingy or so

bold totem
#

Bookmark made

faint oasis
#

You just need to keep in mind, that everythin in the www subdirectory is accessible to everyone knowing the URL - even from the internet, if you have remote access configured.
So you shouldn't use it for any sensitive information.

bold totem
#

Yes

#

Like as a status

faint oasis
#

Not with the HA host. It does not provide any UI.
The only display output it produces is a terminal.

bold totem
#

Nah ill use esps ofc

#

esphome is my best friend

#

Trust in the firmware

bold totem
#

Idk why, but the light doesnt turn on

#

It did sometimes