Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #434: Implement Uptime #700

Merged
merged 1 commit into from
Jul 27, 2023
Merged

Conversation

mathieucarbou
Copy link
Contributor

@mathieucarbou mathieucarbou commented Jul 21, 2023

Example in HA:

mqtt:
  sensor:
    - name: OpenEVSE Uptime
      unique_id: 55806B85-C3B9-4EF7-8DB3-2E6C28D97669
      icon: mdi:clock
      state_topic: "openevse/uptime"
      device_class: duration
      state_class: measurement
      unit_of_measurement: s
      value_template: "{{ value|int }}"
      expire_after: 40

In HA:

image

MQTT Integration: https://gist.github.com/mathieucarbou/92a3d5e0dc38d6b68aa1bdaf153a80c5

In MQTT:

image

/status:

image

/time:

image

api.yml Outdated Show resolved Hide resolved
src/time_man.cpp Outdated Show resolved Hide resolved
models/Status.yaml Show resolved Hide resolved
api.yml Outdated Show resolved Hide resolved
@mathieucarbou
Copy link
Contributor Author

reminder ;-)

src/time_man.cpp Outdated
@@ -258,6 +258,18 @@ String time_format_time(tm &time)
return String(output);
}


// inspired from https://www.snad.cz/en/2018/12/21/uptime-and-esp8266/
// this works if this method is called at least once every 47 days, which is the case (each 8 hours at least based on TIME_POLL_TIME)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no direct link to TIME_POLL_TIME and calling TimeManager::serialise and although chances are high that it would be called, you may want to add something explicit into the loop method. Also be aware that the loop method is only called regularly if SNTP is enabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, I will add a more direct link because here, it works, but I rely on the whole call hierarchy.

@jeremypoulter Regarding the loop which could be disabled...

  • should we then move the update stuff in its own cpp file with its own microtask ?
  • should we couple the uptime code to another existing loop, which is less time-related ?
  • should we keep the uptime code here, and accept the fact that time-related things need NTP ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jeremypoulter : I've updated the PR to move the uptime near the main loop, where the version and hardware info are.

Copy link
Collaborator

@jeremypoulter jeremypoulter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy with this, thanks for the contribution

@jeremypoulter jeremypoulter merged commit 9aa835e into OpenEVSE:master Jul 27, 2023
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants