Hi everyone, I am not a coder, but I am trying my best, so bare with me.
I am trying to create a sensor in my configuration that will pull data from a rest API. This API is accessed using HTTP and returns JSON. This is my current configuration. (I tried to use code block, hopefully it works)
sensor:
- platform: rest
name: WaterSignal_ColesCrossing_Domestic
#ventkey: &ventkey "redacted"
#meterid: &meterid "70802"
resource: 'https://www.watersignal.com/admin2/api/meterdata/authid/redacted/meterid/20069/sdate/2021-07-01-07-00/edate/2021-07-02-12-00/compound/N'
json_attributes:
- meterid
- compound
- meterdata
- stamp
- gallons
- alert
value_template: '{{ value_json.meterdata[0].stamp}}'
device_class: current
authentication: basic
scan_interval: 3600
The code I wrote above was able to function, however, as you will see, start data and end date (sdate, edate) are specified in the URL call. Is it possible for me to write this somehow where it will use the current date for start date and the time from 1 hour ago for end date every time it is called?
I’m sure there is a way to do this easily, but it’s taken me several hours just to piece the above together from forum posts for other hardware.
Thank you.