Hi,
I have the following SQL sensor that gets the last value of a specific month given in the (My)SQL query. Now the LAST_DAY has a “hardcoded” year, is it possible to fill in the current year using a variable or such? Thanks!
- platform: sql
db_url: !secret db_mysql
queries:
- name: sql_kwh_maandelijks_december
query: "SELECT * FROM states WHERE entity_id = 'sensor.energy_import_total_maandelijks_kwh' AND state != 'unknown' AND DATE(created) = LAST_DAY('2020-12-1') ORDER BY state DESC LIMIT 1;"
column: 'state'
unit_of_measurement: kWh