I am afraid it still doesn’t work, - getting the max sensor the highest index.
I understand now how the code works, and the logic should be fine.
Tried to format the index as int, without luck. For the icon it works. This way, if you use CustomUI, the color can be picked up from the sensor, in the customize file.
sensor.nilu_xxx_yyy_pm25:
friendly_name: PM 2.5
templates:
icon_color: >
return attributes.color;
state_sensor = {}
for i in range(len(myData)):
myData[i]['color'] = "#{0}".format(myData[i]['color'])
#myData[i]['index'] = format(myData[i]['index'], "d")
myData[i]['index'] = int(myData[i]['index'])
For the naming of the sensor I added "Nilu", and the location names in the sensors Friendly name gets capital letters.
Enhanced the python code with adding the index text (attribute “index_txt”). This way all information for a sensor i gathered, and less coding is necessary for the front end.
I don’t think it’s possible directly from the API. Even the examples from here is in english (btw, I can’t read in Norwegian too). Of course, you may translate inside the sensor code.
Is the appropriate way to fork your code, and add my tweaking, and then submit a PR?
One question, the newest API return attributes:
fromTime: 2018-11-17T16:00:00+01:00
toTime: 2018-11-17T17:00:00+01:00
timestep: 3600
Is there a way to enhance the code to minimize the API call, so the code will for example call the API at fromTime + timestep + 5 minutes?
This way call the API just when its needed, minimizing the number of API call.
I don’t know… I only know there’s a scan interval which you can set for the sensor, but I’m not aware of a way to schedule a check.
About the code, I think the best way should you fork it and I should put a link to your repository. You should be the new maintainer of this :-). I should visit Norway one day, but until that I have no use for this sensor.