I am trying to create a (Coefficient of Performance) lookup table in Home Assistant, and from what I figured out so far I need to crate JSON file that contains the lookup table data.
The JSON file contains:
{
"temperature": {
"-22": {"COP": 1.40},
"-20": {"COP": 1.52},
"-15": {"COP": 1.54},
"-10": {"COP": 1.57},
"-5": {"COP": 1.70},
"0": {"COP": 1.75},
"5": {"COP": 1.80},
"10": {"COP": 2.04},
"15": {"COP": 2.23},
"17": {"COP": 2.43},
"20": {"COP": 2.61},
"25": {"COP": 2.81},
"30": {"COP": 3.06},
"35": {"COP": 3.20},
"40": {"COP": 3.32},
"45": {"COP": 3.37},
"47": {"COP": 3.40},
"50": {"COP": 3.79},
"55": {"COP": 3.90},
"60": {"COP": 3.91},
"65": {"COP": 3.83},
"70": {"COP": 3.76},
"75": {"COP": 3.71},
"80": {"COP": "N/A"},
"85": {"COP": "N/A"},
"90": {"COP": "N/A"},
"95": {"COP": "N/A"},
"100": {"COP": "N/A"},
"105": {"COP": "N/A"},
"110": {"COP": "N/A"},
"115": {"COP": "N/A"},
"120": {"COP": "N/A"},
"125": {"COP": "N/A"},
"129": {"COP": "N/A"}
}
}
I also seem to need to create a sensor for the file with:
sensor:
- platform: file
name: "COP Data"
file_path: "/config/cop_data.json"
value_template: "{{ value_json }}"
And final sensor for the output:
sensor:
- platform: template
sensors:
heating_cop:
friendly_name: "Heating COP"
value_template: >
{% set temp = states('sensor.current_temperature') | int %}
{% set data = states.sensor.cop_data.state | from_json %}
{{ data.temperature[temp].COP }}
unit_of_measurement: "W/W"
I can’t seem to get the file sensor to work and that leads the Heating COP sensor to show unavailable. Also tried using RESTful Sensor instead of file type with follwing but can’t get that to work either.
- platform: rest
name: COP Data
resource: http://192.168.1.10:8123/local/cop_data.json
value_template: "{{ value_json }}"
Can anyone help me out with what I am doing incorrectly with the syntax or config? What I ultimately want to do is compare the data from lookup table result to my calculated COP and check if its within range (+ or - 10%)