Schnitzel / hass-miner

Controll your Bitcoin miner from Home Assistant
MIT License
59 stars 19 forks source link

Sensor: whether the device is online #298

Open Sjors opened 9 months ago

Sjors commented 9 months ago

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.

b-rowan commented 9 months ago

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) .

Sjors commented 9 months ago

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.

b-rowan commented 9 months ago

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.

Sjors commented 9 months ago

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

Sjors commented 9 months ago

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

b-rowan commented 9 months ago

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

Sjors commented 9 months ago

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
b-rowan commented 9 months ago

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

One of these should work? image

image

pixeldoc2000 commented 4 months ago

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

b-rowan commented 4 months ago

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...

mannebk79 commented 1 month ago

Maybe make it a state attribute with the attributes mining, error, standby, offline? That would solve my issue too as I could just set the the machines values to zero if the state switched to offline