Giter Site home page Giter Site logo

Comments (9)

home409ca avatar home409ca commented on June 14, 2024 3

Can you tell me what to enter in the "Value template"?
I don't know how to react to the result.

Can you give an example?

Thanks

from ha-measureit.

danieldotnl avatar danieldotnl commented on June 14, 2024

But did you also set the value template to divide the value by 3600?

from ha-measureit.

danieldotnl avatar danieldotnl commented on June 14, 2024

{{ (states('sensor.my,sensor_day') | float / 3600) | round(2) }}

from ha-measureit.

home409ca avatar home409ca commented on June 14, 2024

Still counts in seconds...

Below is the recording.
I used templates:
{{ is_state('switch.kitchen_light_left', 'on') }}
{{ (states('sensor.my,sensor_day') | float / 3600) | round(2) }}

and units: h

Ps. When do I use "sensor.my,sensor_day" ? Always? This is independent of the name of the sensor and periods to measure?

ScreenRecorderProject1.mp4

from ha-measureit.

danieldotnl avatar danieldotnl commented on June 14, 2024

Sorry, you are right. I just copied the reply from the forum without testing.
Couple of remarks:

  • the right value_template should be something like {{ value | float / 3600 }}. It should not get the state from the states function as this contains the previous value of the sensor.
  • Even with the right template, it might not do what you expect, and because this is the behaviour when assigning the device_class 'duration'. Device classes influence how the frontend displays data. And I think it does a nice job when you just keep it in seconds. When the value is low, it displays seconds or minutes and when higher, it changes into hours.
  • If you really want a specific format, I think you should create a new config without the device_class (I just found a bug that updating the device_class in the options menu doesn't work). You can then do something like mentioned in this thread.

Hope this helps!!

from ha-measureit.

andersonthomas avatar andersonthomas commented on June 14, 2024

Hi, can u pls enter here how can i change measuring from seconds to hours ? im total programming noob, so i would appreciate to have a code for that. thanks

from ha-measureit.

danieldotnl avatar danieldotnl commented on June 14, 2024

It doesn't work in the current version. I'm working on a new one.
When measuring in hours, what format would you expect/what would the sensor state look like?

from ha-measureit.

andersonthomas avatar andersonthomas commented on June 14, 2024

24h format, so for example 14:37h ;-) thanks

from ha-measureit.

danieldotnl avatar danieldotnl commented on June 14, 2024

Please upgrade to v0.5.4 and read the rewritten README about formatting time sensors.

from ha-measureit.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.