mawinkler / astroweather

Asynchronous Astro Weather Forecast for Home Assistant
GNU General Public License v3.0
69 stars 9 forks source link

uptonight sensor not updating #43

Closed mikewagnercmp closed 9 months ago

mikewagnercmp commented 9 months ago

Hello. Running Home Assistant in a VM on unraid - through a lot of trial and error I figured out how to run uptonight put the files in the /root/homeassistant/www folder in my VM.

during the config, I mapped the uptonight path to that folder. I verified that the .json and plot files are there wit the terminal.

image

here is the debug log but it does not have much:

2023-11-21 00:29:57.746 DEBUG (MainThread) [custom_components.astroweather] Starting up 2023-11-21 00:29:57.746 DEBUG (MainThread) [custom_components.astroweather] Options latitude 41.5824944 2023-11-21 00:29:57.746 DEBUG (MainThread) [custom_components.astroweather] Options longitude -81.2034066 2023-11-21 00:29:57.746 DEBUG (MainThread) [custom_components.astroweather] Options elevation 300 2023-11-21 00:29:57.746 DEBUG (MainThread) [custom_components.astroweather] Options timezone America/New_York 2023-11-21 00:29:57.746 DEBUG (MainThread) [custom_components.astroweather] Update interval 5 2023-11-21 00:29:57.746 DEBUG (MainThread) [custom_components.astroweather] Options cloudcover_weight 3 2023-11-21 00:29:57.746 DEBUG (MainThread) [custom_components.astroweather] Options seeing_weight 2 2023-11-21 00:29:57.746 DEBUG (MainThread) [custom_components.astroweather] Options transparency_weight 1 2023-11-21 00:29:57.746 DEBUG (MainThread) [custom_components.astroweather] Uptonight path /root/homeassistant/www/ 2023-11-21 00:29:57.746 DEBUG (MainThread) [custom_components.astroweather] Connected to AstroWeather platform 2023-11-21 00:29:58.459 DEBUG (MainThread) [custom_components.astroweather] Finished fetching astroweather data in 0.713 seconds (success: True) 2023-11-21 00:29:58.459 DEBUG (MainThread) [custom_components.astroweather] Data update coordinator created (update interval: 5) 2023-11-21 00:29:58.460 DEBUG (MainThread) [custom_components.astroweather] Finished fetching astroweather data in 0.001 seconds (success: True) 2023-11-21 00:29:58.460 DEBUG (MainThread) [custom_components.astroweather] Forecast update coordinator created (update interval: 5) 2023-11-21 00:29:58.460 DEBUG (MainThread) [custom_components.astroweather] Forecast updated 2023-11-21 00:29:58.464 INFO (MainThread) [custom_components.astroweather.binary_sensor] Set up AstroWeather binary sensor platform 2023-11-21 00:29:58.464 INFO (MainThread) [custom_components.astroweather.sensor] Set up AstroWeather sensor platform 2023-11-21 00:29:58.464 INFO (MainThread) [custom_components.astroweather.weather] Set up AstroWeather weather platform

Here is the path in my VM to the files image

Here is what the uptonight sensor states - unknown

image

When i try to use th emarkdown card, it is empty, i would assume b/c the sensor is empty.

if it matters, I am running UpTonight in a docker container, I have the /www folder mapped using SMB and my docker is pushing the files to that folder. I'm sure it is irrelevant since the files are clearly in the folder,

mikewagnercmp commented 9 months ago

As a side note the rest of the astro weather works wonderfully!

mawinkler commented 9 months ago

I believe the error is in the path. The www directory of Home Assistant when running as a container is located here: /config/www from the Home Assistant perspective.

Uptonight does not have any direct interaction with Home Assistant. It simply drops the files to the specified location. As seen in the Readme of AstroWeather, I mount the Home Assistant config directory to local and tell UpTonight to drop the files to www in this directory.

When having debug mode for pyastroweatherio: debug active you should either get a Uptonight imported or uptonight-report.json not found.

mikewagnercmp commented 9 months ago

Ok. I am not using a docker for home assistant. I looked in the code its hard to tell, but it looks like the uptonight_path is just a relative path to /conf/www instead of it being an absolute path to where the files actually were.

Am i correct in assuming that the complete absolute path is uptonight_path/conf/www ?

again, as shown in my screenshot, here is where i have the files no,as per the find command. I set my uptonight_path to this image

mawinkler commented 9 months ago

So, uptonight seems to place the files in the correct location www/. All good here.

You can test this with http(s)://YOUR HOMEASSISTANT:PORT/local/uptonight-plot.png. This should give you the plot in your browser. See hosting files.

The only missing part seems to be a correct path from the home assistant perspective. When running in a container this is /conf/www, in your case this should then be /root/homeassistant/www, I assume (with a starting slash).

mikewagnercmp commented 9 months ago

Good tip - on my instance, http://192.168.1.16:8123/local/uptonight-plot.png gave me the plot just fine, I can also access the txt/json off the same URL http://192.168.1.16:8123/local/uptonight-report.json

So it is JUST the sensor that is not seeming to work for me. In the Astroweather config, I entered /root/homeassistant/www, fire it up, and see it consume the path, however, with the debug logging on I never see the actual uptonight sensor entity say it can or cannot find the file, and if i look at the entity in Ha, it just says "unknown" for the values.

image

I am not a markdown expert, but it think the astroweather sensor is manipulating the data in some way, so I do not think I can just replace the sensor with a path to the .json and have it work, since the markdown is expecting an actual object.

I am delighted that i figured out how to get at least the image plot to the right place. However, the docs on the image were a little confusing, I will have to go through them again as I think there is an option you specified that I did not see in my interface. I did install the add on for the tap-to-zoom.

mawinkler commented 9 months ago

did you set pyastroweatherio to debug in your home assistant configuration?

logger:
  default: warning
  logs:
    custom_components.astroweather: info
    pyastroweatherio: debug

If so, you should either get a "Uptonight imported" or "uptonight-report.json not found. Current path: {self._uptonight_path}/uptonight-report.json". self._uptonight_path will be replaced by the configured value.

Additionally, I just saw that you end the path in the first screenshot with a /, remove this.

mawinkler commented 9 months ago

Good tip - on my instance, http://192.168.1.16:8123/local/uptonight-plot.png gave me the plot just fine, I can also access the txt/json off the same URL http://192.168.1.16:8123/local/uptonight-report.json

So it is JUST the sensor that is not seeming to work for me. In the Astroweather config, I entered /root/homeassistant/www, fire it up, and see it consume the path, however, with the debug logging on I never see the actual uptonight sensor entity say it can or cannot find the file, and if i look at the entity in Ha, it just says "unknown" for the values.

image

I am not a markdown expert, but it think the astroweather sensor is manipulating the data in some way, so I do not think I can just replace the sensor with a path to the .json and have it work, since the markdown is expecting an actual object.

I am delighted that i figured out how to get at least the image plot to the right place. However, the docs on the image were a little confusing, I will have to go through them again as I think there is an option you specified that I did not see in my interface. I did install the add on for the tap-to-zoom.

The sensor being unavailable indicates, that there is no state for the sensor. The markdown just renders the attributes of the sensor when available. The two sensors should look like this:

image
mikewagnercmp commented 9 months ago

Ok I got that logging enabled as per your last comments I see this. I will admint I am confused as that file is exactly where is says it needs to be

image

mikewagnercmp commented 9 months ago

as a side note I checked the file permissions and they were alright, I even set the file to 777 just to make sure there was no chance there was a permission problem.

mawinkler commented 9 months ago

Hm, please try the following in your configuration.yaml:

homeassistant:
  # White list
  allowlist_external_dirs:
    - /root/homeassistant/www
mikewagnercmp commented 9 months ago

welp I fixed it but not how i would have expected - i left the path as the default and it magically pulls in the file.

Only thing I cannot figure out now, is the template image thing. Where in HA do I define a Template Image? when I try to define a template, i have to choose between a binary and some other type of sensor.

image

image

image

mawinkler commented 9 months ago

you can only define sensors and binary_sensors in the UI. All other templates go into yaml. Same here since you define a image type. Documentation

mikewagnercmp commented 9 months ago

Perfect, thank you I will take a look in the morning when I wake up. Thanks again, really appreciate you taking time to talk through this.

I think the file issue is due to the VM image actually is running two docker containers, one for the supervisor and one for home assistant. That would explain why /config/www works, as I suspect it is mapped to the full path I found.

mawinkler commented 9 months ago

Sure thing :-) And I'm happy you find my little projects useful.