Help running a script via AppDaemon

Please excuse the late replies. I’m on the road a lot these days.
It’s really strange. I haven’t changed anything, just the HA update.
It was going so well and suddenly it wasn’t anymore.

You have no idea what else I could try?

Greeting Werner

May be you could try putting the “HTML” in a text file and save it locally, then opening in a browser. May be we would get a clearer view on the “content” of this HTML page and why we don’t receive the precious JSON.

1 Like

Hello,

that was a great idea.
It appears to be a cookie query - see image. But how do I get rid of this?

Greeting Werner

It looks like you are having a login page so the code logon did not work. Did you change password or something like that ?

Hello,

no, I haven’t changed anything. I also checked the password. All right. I think it’s not the login page but the cookie banner at the bottom of the image. As long as I don’t confirm the cookies, it won’t go any further.

Greeting Werner

Hello again,

can I really not be helped anymore?
I took a closer look at the HTML code, it also contains text like (here are some excerpts):

<!-- OneTrust Cookie-Einwilligungshinweis \xe2\x80\x93 Anfang f\xc3\xbcr www.sunnyportal.com -->\r\n  
      <script type="text/javascript" src="https://cdn.cookielaw.org/consent/9b0fa120-418b-4cda-bfed-b1e439ad6f96-test/OtAutoBlock.js" ></script>\r\n     
   <script src="https://cdn.cookielaw.org/scripttemplates/otSDKStub.js"

\'You can see the access to the new SMA\xc2\xa0Online\xc2\xa0Store here. With this you have the option of 
purchasing fee-based add-ons for your Sunny\xc2\xa0Portal systems.\',\r\n                \r\n                    
\'IntroProfessionalPackage\': \'Begin with the Sunny Portal Professional Package and raise monitoring with 
Sunny\xc2\xa0Portal to the next level. With the free-of-charge Demo Package you will receive full access to 
the new functions for four weeks. Further information is available at {{{link}}}.\',\r\n                \r\n                   
 \'IntroShopName\': \'SMA Online Store\',\r\n                \r\n                    \'IntroPlantLogTitle\': \'Update\',\r\n    
            \r\n                    \'IntroPlantLogText\': \'We have optimized the mode of operation of the <strong>PV 
system logbook</strong>.<br>From now on you will see all messages on one page.<br>Confirming events 
will therefore be significantly simpler.\',\r\n                \r\n

This function is unfortunately not currently available for the web browser {0}. Please use an alternative web browser.

 <strong>Your Browser does not support JavaScript!</strong><br>\r\n                                        
JavaScript is required to use Sunny Portal. Enable JavaScript your browsersettings and reload this Website to try again.<br>\r\n       

Unfortunately I don’t have the knowledge to find the error. Therefore I need help.

From my point of view there could be two reasons:

  1. Popup - Cookie Banner https://community-assets.home-assistant.io/original/4X/1/4/4/14461ce8971895ef41a00e49dbcae421e4fecf95.png
    When calling up the URL, a cookie query may appear that must first be confirmed. In the normal browser I can confirm this and it is then saved like this. Unfortunately, I don’t know how I can confirm this in HA.

  2. Any reason resulting from the above HTML texts.

Thank you for any help.

Greeting Werner

1 Like

Did anyone manage to solve this? I get the same issue when trying to fetch PV power value from sunny portal. See my error log below.

BR,
Anders

2023-01-09 15:03:59.849279 WARNING sma: ------------------------------------------------------------
2023-01-09 15:03:59.855036 WARNING sma: Unexpected error in worker for App sma:
2023-01-09 15:03:59.858211 WARNING sma: Worker Ags: {'id': '0f9921aaba224b4ea03fd1fb7037f84f', 'name': 'sma', 'objectid': 'e748f23308f24dcb99f8ef6bd903b181', 'type': 'scheduler', 'function': <bound method sma_bridge.run_every_c of <sma.sma_bridge object at 0x74c54d60>>, 'pin_app': True, 'pin_thread': 1, 'kwargs': {'interval': 300, '__thread_id': 'thread-1'}}
2023-01-09 15:03:59.861148 WARNING sma: ------------------------------------------------------------
2023-01-09 15:03:59.865651 WARNING sma: Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/appdaemon/threading.py", line 904, in worker
    funcref(self.AD.sched.sanitize_timer_kwargs(app, args["kwargs"]))
  File "/config/appdaemon/apps/sma.py", line 45, in run_every_c
    myj = self.getSMAData()
  File "/config/appdaemon/apps/sma.py", line 153, in getSMAData
    myj = json.loads(myhtml)
  File "/usr/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.10/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 3 column 1 (char 4)
2023-01-09 15:03:59.867725 WARNING sma: ------------------------------------------------------------

Unfortunately not. Please let me know if there is a solution here.

Leider nicht. Bitte um Info wenn es hier eine Lösung gibt.