I think it’s a great idea; I’d call it history stats myself.
I think the toughest thing for an inexperienced user would be figuring out the start and end values; they’d have to be documented well enough so that someone not familiar or comfortable with time calculations would be able to understand it conceptually and make use of it. If you could do that, I could see it being a very popular sensor.
Really nice piece of work @bokub! I do have one small problem: how can I put all the history_stats into 1 group? I would normally do that with the group option, but that is not working for the statistics component…
Thank you for the input. For me, and maybe I am just doing things wrong, I look to keep the identifier more technical and friendly_name more friendly. I find using customize: is not consistent when some components allow friendly_names in the config.
From the command line switch component: (which allows friendly names in the config)
When set, the friendly_name had been previously used for API calls and backend configuration instead of the object_id (“identifier”), but this behavior is changing to make the friendly_name for display purposes only. This allows users to set an identifier that emphasizes uniqueness and predictability for API and config purposes but have a prettier friendly_name still show up in the UI. As an additional benefit, if a user wanted to change the friendly_name / display name (e.g. from “Kitchen Lightswitch” to “Kitchen Switch” or “Living Room Light”, or remove the friendly_name altogether), he or she could do so without needing to change existing automations or API calls. See aREST device below for an example.
Perhaps I need to reevaluate my config files and move all my friendly names to the customize component.
Hi @Jokerigno
The state of the component has to be a number, the way this number is formatted has to do with home assistant and not the component itself.
However, I have added an attribute called value which is a nicely formatted version of the state. You can display it by clicking on the component card in the UI.
If you want to display this value without the need of a click, try using the Template sensor component with the following option:
platform: history_stats
name: Marco a casa oggi
entity_id: device_tracker.xxxxxxx
state: ‘home’
start: ‘{{ now().replace(hour=8).replace(minute=0).replace(second=0) }}’
end: ‘{{ now() }}’
platform: template
sensors:
marcoacasaoggi:
friendly_name: ‘Marco a casa oggi’
value_template: ‘{{ states.sensor.marco_a_casa_oggi.attributes.value }}’