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

Ecowitt integration - the sensor ********_wind_direction does not have a 'state_class' attribute #129260

Closed
il77781 opened this issue Oct 27, 2024 · 11 comments · Fixed by #134004
Closed
Assignees

Comments

@il77781
Copy link

il77781 commented Oct 27, 2024

The problem

Good afternoon.
Basically, I outlined the problem in the title: the sensor ********_wind_direction created by Ecowitt integration does not have a state_class: measurement attribute .
Therefore, the values of this sensor cannot be used correctly, for example, with this custom card: https://github.com/aukedejong/lovelace-windrose-card
When specifying the ********_wind_direction sensor in this card for wind_direction_entity, the card is not displayed correctly...
Please add this attribute.

What version of Home Assistant Core has the issue?

core-2024.10.4

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Supervised

Integration causing the issue

Ecowitt

Link to integration documentation on our website

https://www.home-assistant.io/integrations/ecowitt/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No response

Additional information

I understand very little about this, but it seems to me that to solve this problem it is necessary to add a line state_class=SensorStateClass.MEASUREMENT for the EcoWittSensorTypes.DEGREE in the ECOWITT_SENSORS_MAPPING section of the sensor.py file...
If you don't have time to make changes (perhaps much deeper changes are needed than those I suggested), I ask you to indicate what needs to be changed and how - perhaps I can do it myself in my HA...

@home-assistant
Copy link

Hey there @pvizeli, mind taking a look at this issue as it has been labeled with an integration (ecowitt) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of ecowitt can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign ecowitt Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


ecowitt documentation
ecowitt source
(message by IssueLinks)

@Janthenman67
Copy link

I have the same issues, even with more entities. I am on an older version of Ecowiitt, perhaps that is the problem but the newer one broke the connection (SSL issues i think), so I went back. Now HA gives me all kind of repair warnings.

@il77781
Copy link
Author

il77781 commented Dec 15, 2024

@Janthenman67, if we are talking about the "official" Ecowitt integration (and not the one that is available through HACS), then I have found a "temporary" solution for this integration (until the developer finds time to make corrections) ...
If it will be useful to you, I am ready to share my research...

@dwd1
Copy link

dwd1 commented Dec 21, 2024

Pls share it!
I'm migrating yesterday from hacs to the core ecowitt integration because of the next month deadline of the hacs version and I would like to keep the historical wind direction datas.

@il77781
Copy link
Author

il77781 commented Dec 21, 2024

@dwd1, hello!
Initially, I noticed the absence of this attribute because in its absence, the card https://github.com/aukedejong/lovelace-windrose-card did not display any data, but with this attribute everything worked correctly... I have tested this in different conditions and on different sensors...
However, today I installed a new version of this card (1.12.0) - and everything worked without this attribute! The card's author also said that the presence of this attribute does not affect its operation in any way... Therefore, now, it seems, I no longer need to have this attribute (although, of course, I need to check how this will affect the further correct operation, including this card). But I'll tell you how I added this attribute earlier.
All that needs to be done is, as I wrote above, add the line state_class=Sensor State Class.MEASUREMENT for the EcoWittSensorTypes.DEGREE in the ECOWITT_SENSORS_MAPPING section of the sensor.py file.
The most important thing is to find exactly where this file is stored in your operating system...
I use the Home Assistant Supervised, so I will describe the actions for my case. With other Home Assistant installation methods, it is quite possible that the path to this file may be slightly different, but the principle should be the same anyway...
So:

  1. Using the command line, log via SSH into the device where the Home Assistant is installed.
  2. Enter the docker ps command to get a list of all installed containers.
  3. Among all the information displayed on the screen among all the containers, we are looking for a container that apparently belongs to the core of the Home Assistant: something like ghc.io/home-assistant/raspberrypi4-64-homeassistant:2024.12.5 homeassistant, where 2024.12.5 is the version of the Home Assistant core you have installed
  4. Copy [CONTAINER ID] (located in the beginning of the line related to the specified container).
  5. Enter the docker inspect [CONTAINER ID] command, where [CONTAINER ID] is the newly copied id of the specified container
  6. Among all the information displayed on the screen in the GraphDrive section, we are looking for the MergedDir line
  7. Сopy the MergedDir value - this is the file path we need...
  8. Enter the following command:
    sudo nano [MergedDir]/usr/src/homeassistant/homeassistant/components/ecowitt/sensor.py, where [MergedDir] is the path that was just copied.
    It should look something like this:
    sudo nano /var/lib/docker/overlay2/8bef5cecde857f4ae5271dedhjuhfd6721c51840ac946321f9bda851fa4/merged/usr/src/homeassistant/homeassistant/components/ecowitt/sensor.py
  9. At this moment, the file we need (sensor.py) opens in editing mode
  10. Next, in the open file, we need to find the section ECOWITT_SENSORS_MAPPING
  11. In this section, we are looking for lines related to the EcoWittSensorTypes.DEGREE
  12. Add the line state_class=SensorStateClass.MEASUREMENT here
    The end result should look something like this:
),
    EcoWittSensorTypes.DEGREE: Sensor Entity Description(
        key="DEGREE",
        native_unit_of_measurement=DEGREE,
        state_class=Sensor State Class.MEASUREMENT,
),
  1. Save (Ctrl+O, then enter) and close (Ctrl+X) the file sensor.py
  2. Exit the console
  3. Restart the Home Assistant, check for the corresponding attribute, if it does not appear, carefully repeat all the steps.

ATTENTION!!!
THIS ATTRIBUTE WILL REMAIN WITH THE SENSOR ONLY UNTIL A NEW VERSION OF THE HOME ASSISTANT CORE IS INSTALLED! AFTER EACH HOME ASSISTANT UPDATE, ALL THE ABOVE OPERATIONS WILL HAVE TO BE REPEATED (ABSOLUTELY EVERYTHING, SINCE THE CONTAINER WILL CHANGE)!

When restarting the Home Assistant, the attribute does not disappear.

Well, that's about it... I hope this can be useful to someone...

@dwd1
Copy link

dwd1 commented Dec 22, 2024

Thank you!
I have HAOS.
The commands in HAOS is:

docker exec -it homeassistant bash
vi /usr/src/homeassistant/homeassistant/components/ecowitt/sensor.py

@dwd1
Copy link

dwd1 commented Dec 22, 2024

@pvizeli can u add this 1 line to the code?

@il77781
Copy link
Author

il77781 commented Dec 22, 2024

@dwd1, hello!

The commands in HAOS is:

docker exec -it homeassistant bash
vi /usr/src/homeassistant/homeassistant/components/ecowitt/sensor.py

Yes, it can probably be done just as easily in the case of Home Assistant Supervised too... It's just that I have very minimal knowledge in docker and other similar things...
Did you succeed, did you add an attribute?

@il77781
Copy link
Author

il77781 commented Dec 25, 2024

@tkunzfeld, thank you!
But do I understand correctly that in any case it will be necessary to wait for the "approval" of the author?

@tkunzfeld
Copy link
Contributor

Yes I think so. This is my first PR in a project like this and at first I did something wrong with CLA, but I think this should be fixed now and all that is left is the review of the code owner.

gjohansson-ST pushed a commit that referenced this issue Dec 26, 2024
Add state_class to EcoWittSensorTypes.DEGREE (#129260)
@il77781
Copy link
Author

il77781 commented Dec 27, 2024

@tkunzfeld,

Yes I think so. This is my first PR in a project like this and at first I did something wrong with CLA, but I think this should be fixed now and all that is left is the review of the code owner.

Yes, I've been watching what's going on... Thanks!
Now, it seems that all the necessary steps have been completed...
As far as I understand, these changes will appear in the next release of the Home Assistant Core... Right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants