I’m working on adding support for retrieving the weather forecast from Weather Underground.
The data I get back has a number of “periods” - for example, period 0 might be this evening, period 1 is tomorrow, period 2 is tomorrow evening.
I’d like to be able to have the entity_id based on the period number - so in my config I could create a group that has forecast_0, forecast_1, and forecast_2 and those would be the next 3 periods.
However, I’d also like the sensor to set its friendly name to the name of the period. In other words, on Monday I want sensor.forecast_0 to have a friendly name of “Monday Night”, an on Tuesday I want sensor.forecast_1 to have a friendly name of “Tuesday Night”.
It looks like the name property in a sensor is applied both to the entity_id and the friendly_name. That is, if I have my sensor’s name() function return “Monday” then the friendly_name becomes “Monday”, but the entity_id changes to “sensor.monday”.
Is there any way around this? Can I set just a friendly name and leave the entity_id unchanged?
You can change the friendly_name individual of the entity_id via the REST API (check it out via the states developer tool), so I imagine this must be possible via YAML as well. Or are you working in Python?
I solved the problem. In case anyone else runs into this, if you want to keep your entity_id and friendly_name separate, you have to explicitly set self.entity_id in your init function for your sensor. If you don’t set entity_id it will get set to whatever your name is. This happens in entity_component.async_add_entity
Hi cmoore42,
could you kindly explain me how to obtain the forecast from Weather Underground in Home Assistant?
I’m modifying the file wunderground.py to obtain the forecast information as attributes of a new sensor “forecast” (like the alert sensor) but this solution doesn’t fit well into UI.
Thanks in advance
@cmoore42 - Whatever happened to this PR? I was so looking forward to it - the DarkSky daily forecasts are often inaccurate or worded very confusing and I would love to use this Weather Underground instead… any chance you might revive it?
To be honest, I gave up because I was frustrated with the process. I fixed issues with white space not being exactly the same as other code. I fixed issues with comments not being formatted exactly right. I added unit tests. But finally I was told to update documentation, with no information about where the documentation was or how to update it. Since that time the developers have started requiring contributors to sign a licensing agreement with them before being allowed to contribute.
I’ve contributed to many open source projects, including the Linux kernel, and I’ve never seen one that makes it so difficult to contribute. It’s easier for me to just fork off a version of Home Assistant, modify it to work the way I want for my own purposes, and use that.
If anyone wants to take my changes and run with them they’re welcome to. They’re freely available. That’s what open source is all about.
I assume I just need this file in custom_components/sensor/, correct?
I’m sorry you had a bad experience; I’ve been a part of a few opensource projects myself, especially ones that grew very quickly like the fork from Mango to Joomla. They had to put a number of controls and organization things into place as they grew to keep things from going the route of sects of programmers and turf wars as well as controls for the quality of code and of conduct.
I see the evolution of changes since I started here in May and I really think that @balloob is trying to get ahead of all of this and make sure that this project has a long term future with little drama involved. My personal feeling is that he’s making the right moves and that his timing is excellent but I can see where this may discourage some devs who have been at it as long as you and do things a little different.
Although if you have contributed to the Linux kernel, then I think you know how things can go there at times and I think that this is another place where the core contributors have done a good job of setting tone and being open and approachable while still committing to quality of code. Something that’s not easy to do on a two week release schedule and that plays a big part.
Any way, I didn’t intend to disregard your feelings and hope I didn’t while expressing mine. And if you ever decide to change your mind on it, I’d be glad to help if I can. Thanks again for sharing this.
I’m seeing I need const.py as well but not sure where to put it.
EDIT: Nevermind. I see that in order to use this I would have to overwrite the homeassistant/const.py. I thought that I could get away with it because the notes in the pull request from balloob indicated that it wouldn’t be needed.