klaasnicolaas / home-assistant-glow

⚡ The power of energy measurements in your house
https://glow-energy.io/
MIT License
1.02k stars 151 forks source link

Add Uptime Sensor #139

Open pschneider87 opened 2 years ago

pschneider87 commented 2 years ago

I find it useful to have an Uptime Sensor in HA Glow. I've copied right away from the ESPHome-Page from the "Human readable sensor" Section

I'm not so familiar with GitHub, so I'm afraid I can't make a PR :-/ But maybe somebody can quickly copy/paste it into the project, is quite nice to know about it:

image
pschneider87 commented 2 years ago

added https://github.com/klaasnicolaas/home-assistant-glow/pull/142 don't know if @klaasnicolaas needs to do something to make the tests verify the code :-/

klaasnicolaas commented 2 years ago

What about this uptime sensor: https://github.com/klaasnicolaas/smarty-homeassistant-config/blob/master/esphome/sensors/uptime_timestamp.yaml

pschneider87 commented 2 years ago

I'll give that a try. The idea sounds good to only send it once.

klaasnicolaas commented 2 years ago

And?

github-actions[bot] commented 2 years ago

There hasn't been any activity on this issue recently, so we clean up some of the older and inactive issues. Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thanks!

klaasnicolaas commented 2 years ago

Still something that is on my list to add 🤔

mcchots commented 1 year ago

Doesn't this uptime sensor solve this issue?

jessereynolds commented 1 year ago

Yep, I've been using the uptime sensor @mcchots mentions with success. Added the following to the esphome build definition yaml file:

  - platform: uptime
    name: Uptime
    id: sensor_uptime
    update_interval: 60s
spanznet commented 5 months ago

Uptime is great, but rather than have to calculate backwards in time to work out when it last booted, I prefer to add one that updates once on each boot when the time syncs:

text_sensor:
  - platform: template
    name: "Last Boot"
    id: device_last_boot
    icon: mdi:clock
    entity_category: diagnostic

time:
  - platform: homeassistant
    timezone: "Australia/Hobart"
    id: homeassistant_time
    on_time_sync:
      then:
        - if:
            condition:
              lambda: 'return id(device_last_boot).state == "";'
            then:
              - text_sensor.template.publish:
                  id: device_last_boot
                  state: !lambda 'return id(homeassistant_time).now().strftime("%a %d %b %Y - %I:%M:%S %p");'

Which gives you:

image