In my imagination the need for APC to send informations is not needed. I could tell home assistant to read the state of different entities and if those entities are all not availables, trigger a service call. So what I would need and asked for is Home assistant to connect directly to the nas and act as if it was one of the nas compatible APC that sends informations to NAS OS to turn itself off. As I said, this cannot be achieved with ssh.
Addendum:
I’ve seen that Synology has an integration that allows few controls on Synology devices, including shutdown, so I guess it’s possible to call a Shutdown service from Home Assistant to Synology NAS, which is what I’d be looking for. But mine is a Terramaster NAS and I’m starting to guess that to reach the objective, a proper and at least basic Terramaster integration should be created.
At this point I find myself lucky posting the Topic in the right section.
Could a smart and dedicated dev build a generic integration, covering a wide range of protocols from different NAS brands, maybe symply recording those bloody usb signals and making them available to be shot from Home assistant to any NAS through USB or network? My knowledge level is near 0 so forgive me and wake me up if I’m daydreaming.
If the feature request is correct instead, please add this feature as in my opinion it would be very unexpensive to use “old style” UPSs, still in sale and very low budget compared to NAS compatible Network UPS, and let Home Assistant manage automations.
Thanks for any suggestion or (mild) insult
Addendum 2:
I forgot to mention that since Terramaster NAS can also work with SNMP servers, likely reading states of somewhat enity created ad hoc, I also tried understanding how to use SNMP server integration on Home Assistant for the purpose, again with no result.
If there was any way to get the job done using this environment, would anyone help teaching me how such a communication between home assistant and NAS could be established?
Thanks again
What is the specific model for the UPS you are trying to setup?
Thanks for the answer.
Probably I didn’t explain myself, but if you read carefully, I already wrote everything.
I don’t need to set up an UPS since it has nothig to be set up, it’s just a 300w battery with 2 220v AC outputs attached to the main power line.
As I wrote some time already in this topic, what I would need and asked for is Home assistant to connect directly to the NAS and act as if it was one of the NAS compatible APCs that sends informations to NAS OS to turn itself off. As I said, this cannot be achieved with ssh, but probably by using SNMP server, meaning that Home assistant could act as a SNMP server miming a SNMP capable ups, so that the NAS could read some state of some entity and decide it’s time to turn off.
Sorry if I didn’t made myself clear, I’m not english and not using translators, I probably mistook explaining something.
Thanks again
So you you don’t have a proper UPS and need to have battery state sent to Home assistant.
You need to look into a ESP or other type PCB that allows you to read the voltages of the batteries to then send that data into your home assistant instance. Someone with more experience will be best to answer in this regard.
I use an APC UPS via its serial to usb cable plugged into my Synology NAS that is running as a server for NUT intergration to pull that data from into my home assistant instance at this time.
It then uses the Synology integration to tell it when it should shut down and I use the Hass agent on the main PC to send a shut down command as well, when power is restored the HA instance sends a wake on lan command to the PC if it has not turned on via bios setting set to power on which is also set on all primary devices.
Again, no. Please read all above before.
Thanks
I did read… this is why I asked for a specific model, we need data to work with, since you did not state exactly what one you had I worked with reply you made to my question.
Probably my english is rusting, sorry for that. But try not to think about using any communication between UPS and Home assistant and UPS and NAS.
So your entire post is redundant, just set the device to power on when power is restored and use a smart plug with power monitoring with a timer to tell devices when to power off, the only issue with this setup is that you can’t do safe shutdown in the case of a NAS and you risk data loss for anything that is pending to be written at the time of sudden shutoff.
That’s what I want to do and that’s the problem. However I still don’t know how to make Home assistant turn of the NAS and in which way they can communicate
Without a data line you can’t, solutions were provided.
You need to look into a ESP or other type PCB that allows you to read the voltages of the batteries to then send that data into your home assistant instance. Someone with more experience will be best to answer in this regard.
The NAS is tied via the integration and if there is no integration use a smart plug tied to the timer of the main plug being used for the detection of power loss.
edit: a quick look up for Terramaster NAS’s gives this post
I would think about a ping to a device of your choice that is not under the UPS protection, if ping fail, this is the condition to trigger the NAS shutdown. Homeassistant provide a ping integration. Ping (ICMP) - Home Assistant
Now you must find a way to remote control your NAS, the simplest way is ssh or telnet. Or you can reverse the http api being called when you do the shutdown from it’s management web interface. If you could make a script to achive the shutdown, then you have all you need to create an automation in Homeassistant that power off your NAS and can, eventually, power off HA itself.
I understand that is not a complete and a step by step how to, but the tickyest part is the NAS one, and without the phisical device itself it’s not possibile to help further.
Maybe you can have a look at this post to start : How to log in to the SSH terminal? - TerraMaster Official Forum
Federico
So my read is the UPS part is irrelevant. What you’re really looking for is the option to shutdown your NAS from HA. Does your NAS not have SSH?
Yes! You got it! Thanks!
My NAS has ssh, the problem seems, as I breefly mentioned, that it’s not possible to ssh login to NAS OS (Terramaster TOS 5.1) without user interaction, thus no automation is possible.
I tried creating:
shell_command:
shutdown_tnas: echo YOURTNAS_ADMIN_PASSWORD | ssh -i /config/ssh/id_rsa -o 'StrictHostKeyChecking=no' -p 9222 admin@YOUR_TNAS_IP sudo -S poweroff
and various modifications of this code using my credentials, but calling shell_command service never worked, giving back login errors in logs. I could replicate the problem and paste the code if needed, but searches made a while ago brought me to someone else’s conclusion that it’s a TOS security limitation. Further research would be needed…
I also tried to understand how to make HA act as a SNMP server (which should be possible somehow), since TOS should be able to monitor it and react consequently, but I couldn’t find anything about such configuration hence a way to make it work either. Also, for this to work, HA should have to be able to change the states of SNMP server entities while running and, again, I don’t know if it’s even possible. Again further research would be needed…
That’s why I was asking for a direct integration or another, possibly the simplest, way to tell the damn NAS to shut off remotely.
As you correctly stated, in my circumstance UPS has nothing to do with this job, it just has to keep router, NAS and RPi5 (HA) running while the “power off” automation is launched by HA and NAS shuts off. Once the job is done and NAS is off, the UPS can quietly die and hopefully resurrect as soon as AC is back, it doesn’t matter. Any battery with sufficient juice can do that.
Moreover, creating trigger conditions to eventually lanch a “shutdown NAS service call” within an automation is easy indeed on HA. I can monitor any plug, switch, light etc. connected to HA to tell that my home main power supply is gone, so, in my ignorant opinion, there’s no need for a smart UPS. Literally everything controlled by HA that’s not under UPS (and that then goes off as soon as AC goes off) can be monitored for this purpose directly by HA.
So what I actually need and asked for since the beginning (my english must have rot lately) is: once power has gone, HA red that all conditions were met (different devices unavailables), and triggered the automation I wrote to protect fragile devices such as NAS, what kind of service, if existing, can lauch a Power off signal to NAS without using ssh?
I think this is the best explanation I can give, so
thanks everyone for help,
but a lot more thanks to you and to those who took time to read and understand.
P.s. Sorry for late reply, I couldn’t post more than 5 in few hours since it’s my first day.
P.p.s. building a mechanical finger to physically push the power button on command would require way more than just further research for me and probably cost more than a compatible network APC, so this solution won’t be considered untill further research tells I’m wrong.
This is something that could turn out to be useful, but I wouldn’t know how since it’s just reading TOS sensors, no active interaction is involved. Maybe someone more skilled than me could know something more
The phisical finger statement let me think about a device that i know as “finger bot”, but i don’t know if its true name. There are many versions, wifi or zigbee, and you can create a custom padding with some plaster if the gap between the actuator and NAS power button is too wide.
However, i suggest to leave the SNMP server idea and focus on Terramaster OS. The link i poste previously state that IS possible to connect già SSH the NAS. Note that the procedure is different for TOS 5. Please ala check if SSH should be enabled from the TOS management interface.
I suggest you do some test from your pc and when you’ll find the correct login procedure, you can configure SSHD on the NAS to accept connection without password from a pc that provide a know public key (so called “SSH key based auth”), and even istruct “sudo” command to perform the “poweroff” without a password. But all of this is “advanced” Unix stuff, not an Homeassistant problem. Don’t mean to be rude, my apologize in advance.
Federico
Tried that, as I said, it didn’t work. TOS 5.1 apearently won’t let me automatically login. I regularly use linux ssh on different systems and I thought that would have made things easier. Sure enough I can ssh login from ubuntu terminal to TOS cli and act sudo as much as I want, but I cannot create a service to shut it down automatically.
I’d like to keep autentication on since the system is partly exposed to the web.
I didn’t know about finger-bots, but they actually exist. If noone finds a software solution, you got it.
Thanks
Basically create a script on pi that ssh into server and shuts it down. Run script from an automation. Sounds like you also need to add device to monitor power that works with HA