Closed arboeh closed 1 year ago
It works :-D Got it work myself, but the format for "pvfusionminutecron" doesn't work as meantioned in the docu. The format 0,30 gives an error:
2022-10-10 15:20:56,304 - root - DEBUG - Pulled 'pvfusionminutecron=0,30' from the environment
Traceback (most recent call last):
File "/code/pv.py", line 19, in <module>
conf = PvConf(logger)
File "/code/pvconf.py", line 8, in __init__
self.apply_environment_settings()
File "/code/pvconf.py", line 141, in apply_environment_settings
self.fusionminutecron = int(self.getenv("pvfusionminutecron"))
ValueError: invalid literal for int() with base 10: '0,30'
How often is it possible to pull the API?
If you set the minutes in the scheduler the request is made each hour at the minutes set. For example, if you set the minutes to 30, the task will launch at 0:30, 1:30, 2:30, not each half hour.
The correct syntax is:
sched.add_job(self.process_fusionsolar_request, trigger='cron', hour=self.conf.fusionhourcron, minute='0, 30')
or
sched.add_job(self.process_fusionsolar_request, trigger='cron', 'interval', hours=0.5)
Hi Jorge and arboeh, Nice to see you two have been using this project. Its good to see that the effort of sharing the code helps others out.
The cron behaviour of triggering each full half our on the clock is actually intended. Initially I used a 30min timer, but this resulted in problems in displaying the solar production and grid usage data on pvoutput.org. I'll elaborate; pvoutput.org puts data in 15min intervals of the clock (0:15, 0:30, 0:45, 1:00, etc). Because fusionsolar only refreshes each half our, the fusionsolar data and grid usage data must be kept in sync. That's why I use cron to trigger fusionsolar on each half our on the clock, instead of each half our from a random start time.
I'll demonstrate from pvoutput.org, this is what the cron sync achieves:
Without it, data looks like this
I have problems using this project with an existing Home Assistant instance and the MQTT Broker addon from HA. I just need the connection to FusionSolar-Kiosk and MQTT-Entities in HA. I don't need another MQTT server and the InfluxDB stuff. Unfortunately MQTT Explorer doesn't show up topic "energy/pyfusionsolar" I modified the composer file to my need and created an user for the MQTT broker, but I'm not sure which port (1883/9001) and host (HA host, 0.0.0.0, localhost) to use to connect to the HAs' MQTT broker:
Portainer-Log: