Schnitzel/hass-miner

Sensor: whether the device is online

Sjors opened this issue · 10 comments

I have a Home Assistant notification that reminds me to give the S9 power if electricity is cheap in the next couple of hours. I'd like to avoid that notification if it's already powered on.

I power it on manually, despite having a smart switch, because sometimes the PSU fans run but the board doesn't start. So I may need to try again a few times.

I could already avoid the notification by checking if the smart socket is on, or check if it consumes more than 7 watt (only PSU) and less than 15 (board probably working).

But it'd be nicer to just have a binary_sensor like s9_online.

Can this be compared to the switch entity? Technically the switch state is set by the result of is_mining in pyasic, which should indicate whether the miner is in shutdown mode or not (except in the case of #294, which is a bug) .

Well the switch only says if it's mining, right? But when it's not mining I don't know if it's offline or online but not mining.

Yeah, ok, this is sortof a subissue to 294, in that the device itself should just report as unfindable or fully offline when its powered off, but report not mining when its in shutdown mode, if that makes sense?

In any case, ill try to figure out a full fix tonight.

I care mostly about whether it's confirmed online. Whether it's offline, unreachable, powered off is less important.

So perhaps whenever a poll succeeds the sensor is set to Online, when it fails it's set to Offline.

Does v1.1.1rc1 fulfil these requirements? You should be able to check if the miner is available?

When I try to add this as a condition to an automation, I don't see "available" in the dropdown, at least not when selecting the device.

Scherm­afbeelding 2024-01-25 om 19 44 55

You should be able to do it on the entity, doesn't seem like devices support unavilable?

One of these should work?
image

image

Maybe use HA ping to check if miner IP is responding?

Maybe use HA ping to check if miner IP is responding?

This isn't really the problem, the issue is how to display it. I already know if the miner is offline (await pyasic.get_miner(ip) is None), I just don't know how to display it the intended way...