Probably not. That’s a frontend issue. I’m more concerned about backend issues like making it more useful for automations and template sensors. As it is I’ve broken the rules by making it local time instead of UTC. In the famous words of Lou Costello, “I’m a bad boy!”
Probably. I really don’t understand the idea of making datetime attributes UTC. If they were naive datetimes, then maybe. But they’re time zone aware datetimes, so whether they’re local time or UTC makes absolutely no difference when using them in calculations. But making them local sure makes it easier for a human reading them.
I still have to consult a model in my head about if a time zone is east or west, which way the earth turns as to whether the offset is ahead of me or behind me (day wise)
The backend can’t really do that, since it doesn’t know when it will be displayed. However, you can certainly create a template sensor with {{ state_attr('sensor.sun_is_up', 'next_change") }} and then set its device_class to timestamp so the frontend can display it that way.
Hi Phil,
thanks, but you’re confusing me now…
the screenshot I posted contains only the entities you’re component has made, without any template or setting in device_class on my behalf.
that’s why I would have hoped it to be possible you set the same format for these next_changes attributes directly in the component itself.
Hi, today i have strange behaviour of the sun2 component.
Now it’s 12:06pm in my place and i discovered this inside the sun2 component related to the sun elevation:
While the default sun integration shows at the same time:
As you see the right elevation comes from the default sun.
How is it possible the sun2 component is so wrong?
All my automations went crazy since this morning…
That happened also tonight with the same behaviour:
the sensor.elevation stopped at -66.5 degree as you can see and the time now is 10:27am.
The right elevation at this moment is 23.04.
In the log i see:
2019-11-30 00:55:48 ERROR (MainThread) [homeassistant.helpers.entity] Update for sensor.elevation fails
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 270, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 448, in async_device_update
await self.async_update()
File "/config/custom_components/sun2/sensor.py", line 117, in async_update
self._update()
File "/config/custom_components/sun2/sensor.py", line 316, in _update
rnd_elev + _ELEV_RND, self._sol_noon - _PEAK_MARGIN)
File "/config/custom_components/sun2/sensor.py", line 250, in _get_nxt_time
nxt_time = _calc_nxt_time(time0, elev0, time1, elev1, trg_elev)
File "/config/custom_components/sun2/sensor.py", line 216, in _calc_nxt_time
time0 + (time1 - time0) * ((trg_elev - elev0) / (elev1 - elev0)))
ZeroDivisionError: float division by zero
Thanks for the details, and sorry this isn’t working for you. I’ll see if I can spend some time in the next few days to work on a fix. Could you tell me your GPS coordinates (via a PM) or at least tell me roughly in what part of the world you are so I can try to reproduce this?
Is anyone else having trouble updating to the latest version thru HACS?
it says 1.5.0 is available and I can click to update and it says restart required but when I restart HA it goes right back top saying that 1.4.0 is installed.
Then if I check the files that are downloaded I don’t have the binary_sensor.py or helpers.py that are in the repo.
I haven’t personally tried it. I gave up on HACS a long time ago. Seems more work than it’s worth. But, if someone can figure out if there’s something I need to change to make it work I’m happy to do it. I just don’t want to keep trying to keep up with HACS; it’s too painful.
EDIT: FWIW, someone noted problems with HACS above. See:
Just browsing the latest HACS docs for developers, there seems to be (at least) two new requirements. The repository is supposed to have “topics.” I didn’t have those. Just added a couple. Not sure how much difference this makes.
It also now seems to require a new hacs.json file. I have not created that. No idea what not having that file does to HACS’ ability to use my repository.
I think those changes are only for new repos… when you’re in it should work anyway. As I said I updated via HACS ok. My own custom component also updates ok…