Hey, thanks for your continued work on this. Not sure if you can help, but I’ve been trying to track when my son’s gaming PC is on, and he’s pretty good at dodging detection.
I’ll provide more detail than we need, just incase it adds context or triggers something in your mind that I’ve missed.
First attempt:
I started with a power monitoring socket, but it was easy for him to plug it in via another outlet.
Second attempt:
Then I tried a simple ping checker provided natively in HA:
binary_sensor:
- platform: ping
host: 10.13.1.241
name: "Gaming PC"
scan_interval: 60
That worked for a while, but then he started running his wifi network under the public profile, so ping requests got refused.
Third attempt:
Rather than try to force his profile, I then looked to this velop integration to see if I could get a on/off from the particular device. His PC is known to the mesh, and has a static IP.
Question: Whilst the velop integration creates device_tracker entities for all iPhones that join my wifi, I don’t see anything for his PC. Is there a way I can make it show this device?
Failing that, the most compact version I’ve found to track the device is to ask the node nearest him to iterate the devices that are connected, convert each to a string, and return a 1 if the result includes the text ‘gaming’. I’m sharing the config here:
binary_sensor:
- platform: template
sensors:
gaming_pc_connected:
friendly_name: Gaming PC Is On
value_template: "{% for item in (state_attr('sensor.velop_kids_room_connected_devices','devices')) %}{% if 'gaming' in item | string %}1{% else %}{% endif %}{% endfor %}"
That kind of works, with the following constraints:
- devices are connected, including the gaming PC → ‘on’
- devices are connected, excluding the gaming PC → ‘off’
- no devices are connected → ‘unavailable’
Question: is there a better / easier way to track the above so that I get an on/off?
What I’ve got does work, and with the current output I can show the time spent today, and in total over the last ten days using:
sensor:
- platform: history_stats
name: Gaming PC Ten Day ON
entity_id: binary_sensor.gaming_pc_connected
state: "on"
type: time
end: "{{ now().replace(hour=23, minute=59, second=59) }}"
duration:
days: 10
- platform: history_stats
name: Gaming PC ON today
entity_id: binary_sensor.gaming_pc_connected
state: "on"
type: time
start: "{{ now().replace(hour=0, minute=0, second=0) }}"
end: "{{ now() }}"
This lets me flash his lights when he approaches his daily allowance, and the ten day tally affords me some discretion via contextualising his recent usage.
TL/DR
The integration is great. It lets me detect if a specific device is connected to a particular node on my network, and trigger actions based upon its presence and tallies of time elapsed within a given period. But am I going 3 sides of a square to get this control?
Cheers!