SmartBoatInnovations / ha-smart0183tcp

Smart Boat 0183 TCP Integration
https://smartboatinnovations.com/
Other
10 stars 1 forks source link

HA - Statics #4

Open alnavasa opened 2 months ago

alnavasa commented 2 months ago

Hi, Can we change the kind of sensor for HA so it has statics on it?

https://developers.home-assistant.io/docs/core/entity/sensor/#long-term-statistics

I think it is as "easy" as adding this: state_class: measurement

This way graphs are more dynamic, and pulling max value for a period of time is easier.

Thanks for all your work, loving this, and loving your FB posts!!

SmartBoatInnovations commented 2 months ago

Thank you for your feedback and support! I'm glad you're enjoying the integration and my Facebook posts!

Regarding your request, in the Smart0183tcp.json file, I do have unit_of_measurement defined for many entities. However, simply adding state_class: measurement is not enough to enable long-term statistics.

For statistical graphs and long-term statistics in Home Assistant, having a unit_of_measurement is what makes the system correctly handle the sensor's data. The unit_of_measurement helps Home Assistant understand the type of data (like °C, W, etc.) being recorded, which is necessary for proper graphing and historical data analysis.

From my observations, having the unit_of_measurement is usually sufficient for statistical graphs, but including both can offer more flexibility for long-term statistics.

Could you let me know which specific entities aren't working in statistics? I'll be happy to look into them. Alternatively, feel free to update the JSON file with the necessary unit_of_measurement changes, and I'll review and release it.

alnavasa commented 2 months ago

Hi, I have zero JSON knowledge, actually non programing knowledge, doing small things with easy esphome. That's why I said it is as "easy" as adding.... Becase I have no knowledge,

I wanted to see stats with the wind speed, currently in my system I am using sensor.ii_mwd_5, that does have Knots units.

This is the kind of graph it shows, and stats card to get max and min value doesn't work either

Captura de pantalla 2024-09-25 a las 23 07 37

I have changed the flowing with no luck

Original:

            {
                "name": "MWD 5",
                "unique_id": "MWD_5",
                "full_description": "Wind speed",
                "short_description": "Wind speed MWD_5",
                "unit_of_measurement": "#6"
            },

Mod:

            {
                "name": "MWD 5",
                "unique_id": "MWD_5",
                "full_description": "Wind speed",
                "short_description": "Wind speed MWD_5",
                "unit_of_measurement": "#6",
                "state_class": "measurement"
            },
SmartBoatInnovations commented 2 months ago

I am a little confused. The captura pantalla looks good. What type of graph do you want?

Better do not change the JSON.

But you can create a new helper template sensor (say wind_speed) in HA using sensor.ii_mwd_5 as an input and there you can add extra attributes.

settings > devices & services > helpers > create helper > template

this is the code {{ states('sensor. ii_mwd_5 ') }} and there you can add whatever class and measurement you like.

Rob

On Wed, 25 Sept 2024 at 23:24, alnavasa @.***> wrote:

Hi, I have zero JSON knowledge, actually non programing knowledge, doing small things with easy esphome. That's why I said it is as "easy" as adding.... Becase I have no knowledge,

I wanted to see stats with the wind speed, currently in my system I am using sensor.ii_mwd_5, that does have Knots units.

This is the kind of graph it shows, and stats card to get max and min value doesn't work either Captura.de.pantalla.2024-09-25.a.las.23.07.37.png (view on web) https://github.com/user-attachments/assets/6b7c96b7-9d9e-44bf-8e9c-0d47b73979d7

I have changed the flowing with no luck

Original:

        {
            "name": "MWD 5",
            "unique_id": "MWD_5",
            "full_description": "Wind speed",
            "short_description": "Wind speed MWD_5",
            "unit_of_measurement": "#6"
        },

Mod:

        {
            "name": "MWD 5",
            "unique_id": "MWD_5",
            "full_description": "Wind speed",
            "short_description": "Wind speed MWD_5",
            "unit_of_measurement": "#6",
            "state_class": "measurement"
        },

— Reply to this email directly, view it on GitHub https://github.com/SmartBoatInnovations/ha-smart0183tcp/issues/4#issuecomment-2375289152, or unsubscribe https://github.com/notifications/unsubscribe-auth/BC34PQWR2CEBRY2HGC4GHA3ZYMSYFAVCNFSM6AAAAABO2V2YAGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNZVGI4DSMJVGI . You are receiving this because you commented.Message ID: @.***>

alnavasa commented 2 months ago

I am a little confused. The captura pantalla looks good. What type of graph do you want? Better do not change the JSON. But you can create a new helper template sensor (say wind_speed) in HA using sensor.ii_mwd_5 as an input and there you can add extra attributes. settings > devices & services > helpers > create helper > template this is the code {{ states('sensor. ii_mwd_5 ') }} and there you can add whatever class and measurement you like. Rob On Wed, 25 Sept 2024 at 23:24, alnavasa @.> wrote: Hi, I have zero JSON knowledge, actually non programing knowledge, doing small things with easy esphome. That's why I said it is as "easy" as adding.... Becase I have no knowledge, I wanted to see stats with the wind speed, currently in my system I am using sensor.ii_mwd_5, that does have Knots units. This is the kind of graph it shows, and stats card to get max and min value doesn't work either Captura.de.pantalla.2024-09-25.a.las.23.07.37.png (view on web) https://github.com/user-attachments/assets/6b7c96b7-9d9e-44bf-8e9c-0d47b73979d7 I have changed the flowing with no luck Original: { "name": "MWD 5", "unique_id": "MWD_5", "full_description": "Wind speed", "short_description": "Wind speed MWD_5", "unit_of_measurement": "#6" }, Mod: { "name": "MWD 5", "unique_id": "MWD_5", "full_description": "Wind speed", "short_description": "Wind speed MWD_5", "unit_of_measurement": "#6", "state_class": "measurement" }, — Reply to this email directly, view it on GitHub <#4 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/BC34PQWR2CEBRY2HGC4GHA3ZYMSYFAVCNFSM6AAAAABO2V2YAGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNZVGI4DSMJVGI . You are receiving this because you commented.Message ID: @.>

I want to use this other card: https://www.home-assistant.io/dashboards/statistics-graph/ and also being able to use this card: https://www.home-assistant.io/dashboards/statistic/

But both won't let me use the sensor provided by the entity because it doesn't have the state class: measurement.

I can create the helper, as a work around, but I wa looking into fixing the root of the issue, That was plan B!

SmartBoatInnovations commented 1 month ago

Sorry been sailing for a few weeks but I have released a new update that will set state class: measurement for all entities created. Please test and confirm that your Stats cards now work.

alnavasa commented 1 month ago

Great man!

It's working with all that static's!

Thanks for the work!