Achronite / mqtt-energenie-ener314rt

MQTT interface for Energenie ENER314-RT add-on board for the Raspberry Pi, designed for use by Home Assistant.
MIT License
13 stars 5 forks source link

Add Heat_Demanded sensor to eTRV #96

Open genestealer opened 6 days ago

genestealer commented 6 days ago

I'm struggling to understand how to add a Heat_Demanded sensor the the 3.json for eTRV's.

Can you please check my logic? I think the val_tpl is wrong is looks like the '~TEMPERATURE/state' is not being set to 'energenie/3/4335/TEMPERATURE/state'

       {
         "id": "Heat_Demanded",
         "component": "binary_sensor",
         "stat_t": "~HEAT_DEMAND/state",
         "config": {
           "ic": "mdi:fire",
           "dev_cla": "heat",
           "val_tpl": "{{ states('~TEMPERATURE/state') | float < states('~TARGET_TEMP/command') | float }}",
           "pl_on": "true",
           "pl_off": "false"
         }
      },   
genestealer commented 6 days ago

Also tried with little little success (spent 3 hours) to get just the delta temperature :(

      {
         "id": "Heat_Delta",
         "component": "sensor",
         "stat_t": "~HEAT_DELTA/state",
         "config": {
           "ic": "mdi:fire",
           "val_tpl": "{% states('~@/TEMPERATURE/state') | float - states('~@/TARGET_TEMP/command') | float %}"
         }
      }, 

also tried to play with the substituting @ placeholders in app/js without any luck

// replace @ in topics with the address where each of the data items are published (state) or read (command)

console.log("Substituting @ placeholders for:", parameter.id);

if (parameter.stat_t){
    console.log("Original stat_t:", parameter.stat_t);
    dmsg.stat_t = parameter.stat_t.replace("@", `${parameter.id}`);
    console.log("Updated stat_t:", dmsg.stat_t);
}

if (parameter.cmd_t){
    console.log("Original cmd_t:", parameter.cmd_t);
    dmsg.cmd_t = parameter.cmd_t.replace("@", `${parameter.id}`);
    console.log("Updated cmd_t:", dmsg.cmd_t);
}

if (parameter.act_tpl){
    console.log("Original act_tpl:", parameter.act_tpl);
    dmsg.act_tpl = parameter.act_tpl.replace("@", `${parameter.id}`);
    console.log("Updated act_tpl:", dmsg.act_tpl);
}

if (parameter.val_tpl){
    console.log("Original val_tpl:", parameter.val_tpl);
    dmsg.val_tpl = parameter.val_tpl.replace("@", `${parameter.id}`);
    console.log("Updated val_tpl:", dmsg.val_tpl);
}
Achronite commented 6 days ago

Isn't this what the climate entity for the eTRV already does?

Call_For_Heat = {{ is_state_attr('climate.radiator_4280_climate_control', 'hvac_action', 'heating') }}
genestealer commented 4 days ago

Hi, How are you doing hvac_action? I cannot see it anywhere in your code?

On a separate, but related note, can you advise how the "val_tpl" should be formatted? I have made a guess, but it's making my head spin.


     {
      "id": "TARGET_TEMP_DELTA",
      "component": "sensor",
      "stat_t": "~@/state",
      "config": {
          "dev_cla": "temperature",
          "unit_of_meas": "°C",
          "val_tpl": "{{ (TEMPERATURE | float) - (TARGET_TEMP) | float)) | round(2) }}"
         }
      },
      {
         "id": "HEAT_DEMANDED",
         "component": "binary_sensor",
         "stat_t": "~@/state",
         "config": {
             "val_tpl": "{% if (TEMPERATURE | float) <= (TARGET_TEMP) | float) %} true {% else %} false {% endif %}",
             "dev_cla": "running"
         }
      },
Achronite commented 4 days ago

How are you doing hvac_action? I cannot see it anywhere in your code?

It is the climate entity (Climate_Control) that does it for you; it is the first thing in the 3.json file. The mode (valve_state) works in combination with the target_temp/temperature to give the implied state of the HVAC.

I'm not expert on templates for your formatting, I would try the community.