It needs to write to ‘standard output’. In other words, if you are at the Linux command line and execute your script, it’s output should appear on the command line (‘standard output’).
Here’s an example of a command line sensor calling a python script:
Here’s an example using shell script but it’s the same principal.
Yes i am, it can find the the script. i chmod 755. I made another script with just print("hello") and that worked so i started to add code until it failed and as far as i can see as soon as i try to use response.content the script fails but if i do print(response) i get 200 so i don’t know what’s going on
Traceback (most recent call last):
File "./herlev_affald.py", line 14, in <module>
cleaned = ((response.content.replace('"d":"{', '"d":{')).replace('}]}"', '}]}')).replace('\\','')
TypeError: a bytes-like object is required, not 'str'
I’ve encountered a hurdle. I have trouble making the script work for me because my locale is not Danish. If I comment out the line that sets the locale, strptime fails to perform the date conversion. In my locale (English Canada), %A and Fredag are incompatible (no surprise there).
All I want to do is try running the script from within Home Assistant to see if I get the same error message as you. Later I will try simplifying the python script just enough so it works for my locale.
Yes you are on to something, i also nailed it down to datetime_object = datetime.strptime(y['d']['list'][5]['toemningsdato'], '%A den %d-%m-%Y')
maybe because the locale i set isn’t working so strptime is failing…i am too tired now so i can’t concentrate anymore. I will hit the bed…damn it…
@123 Thank you very much, indeed this a solution which solves the problem and works. Weird the one with setting the locale didn’t work. Now i will continue to make a binary sensor that can check the date towards today so i can make an automation to send notification.