add global values for per-sensor calibration table;
This commit is contained in:
@@ -49,6 +49,43 @@ ads1115:
|
|||||||
i2c_id: bus_ads
|
i2c_id: bus_ads
|
||||||
address: 0x48
|
address: 0x48
|
||||||
|
|
||||||
|
globals:
|
||||||
|
- id: hb1_wet_voltage
|
||||||
|
type: float
|
||||||
|
restore_value: yes
|
||||||
|
initial_value: '1.20'
|
||||||
|
- id: hb1_dry_voltage
|
||||||
|
type: float
|
||||||
|
restore_value: yes
|
||||||
|
initial_value: '2.70'
|
||||||
|
|
||||||
|
- id: hb2_wet_voltage
|
||||||
|
type: float
|
||||||
|
restore_value: yes
|
||||||
|
initial_value: '1.20'
|
||||||
|
- id: hb2_dry_voltage
|
||||||
|
type: float
|
||||||
|
restore_value: yes
|
||||||
|
initial_value: '2.70'
|
||||||
|
|
||||||
|
- id: hb3_wet_voltage
|
||||||
|
type: float
|
||||||
|
restore_value: yes
|
||||||
|
initial_value: '1.20'
|
||||||
|
- id: hb3_dry_voltage
|
||||||
|
type: float
|
||||||
|
restore_value: yes
|
||||||
|
initial_value: '2.70'
|
||||||
|
|
||||||
|
- id: hb4_wet_voltage
|
||||||
|
type: float
|
||||||
|
restore_value: yes
|
||||||
|
initial_value: '1.20'
|
||||||
|
- id: hb4_dry_voltage
|
||||||
|
type: float
|
||||||
|
restore_value: yes
|
||||||
|
initial_value: '2.70'
|
||||||
|
|
||||||
switch:
|
switch:
|
||||||
- platform: gpio
|
- platform: gpio
|
||||||
name: "Bewässerung Hochbeet 1"
|
name: "Bewässerung Hochbeet 1"
|
||||||
@@ -206,10 +243,10 @@ sensor:
|
|||||||
update_interval: 2s
|
update_interval: 2s
|
||||||
icon: "mdi:water-percent"
|
icon: "mdi:water-percent"
|
||||||
lambda: |-
|
lambda: |-
|
||||||
const float wet_voltage = 1.20;
|
float wet_voltage = id(hb1_wet_voltage);
|
||||||
const float dry_voltage = 2.70;
|
float dry_voltage = id(hb1_dry_voltage);
|
||||||
float v = id(b4_sensor1).state;
|
float v = id(b4_sensor1).state;
|
||||||
if (isnan(v)) return NAN;
|
if (isnan(v) || dry_voltage <= wet_voltage) return NAN;
|
||||||
float p = (dry_voltage - v) * 100.0f / (dry_voltage - wet_voltage);
|
float p = (dry_voltage - v) * 100.0f / (dry_voltage - wet_voltage);
|
||||||
if (p < 0) p = 0;
|
if (p < 0) p = 0;
|
||||||
if (p > 100) p = 100;
|
if (p > 100) p = 100;
|
||||||
@@ -225,10 +262,10 @@ sensor:
|
|||||||
update_interval: 2s
|
update_interval: 2s
|
||||||
icon: "mdi:water-percent"
|
icon: "mdi:water-percent"
|
||||||
lambda: |-
|
lambda: |-
|
||||||
const float wet_voltage = 1.20;
|
float wet_voltage = id(hb2_wet_voltage);
|
||||||
const float dry_voltage = 2.70;
|
float dry_voltage = id(hb2_dry_voltage);
|
||||||
float v = id(b4_sensor2).state;
|
float v = id(b4_sensor2).state;
|
||||||
if (isnan(v)) return NAN;
|
if (isnan(v) || dry_voltage <= wet_voltage) return NAN;
|
||||||
float p = (dry_voltage - v) * 100.0f / (dry_voltage - wet_voltage);
|
float p = (dry_voltage - v) * 100.0f / (dry_voltage - wet_voltage);
|
||||||
if (p < 0) p = 0;
|
if (p < 0) p = 0;
|
||||||
if (p > 100) p = 100;
|
if (p > 100) p = 100;
|
||||||
@@ -244,10 +281,10 @@ sensor:
|
|||||||
update_interval: 2s
|
update_interval: 2s
|
||||||
icon: "mdi:water-percent"
|
icon: "mdi:water-percent"
|
||||||
lambda: |-
|
lambda: |-
|
||||||
const float wet_voltage = 1.20;
|
float wet_voltage = id(hb3_wet_voltage);
|
||||||
const float dry_voltage = 2.70;
|
float dry_voltage = id(hb3_dry_voltage);
|
||||||
float v = id(b4_sensor3).state;
|
float v = id(b4_sensor3).state;
|
||||||
if (isnan(v)) return NAN;
|
if (isnan(v) || dry_voltage <= wet_voltage) return NAN;
|
||||||
float p = (dry_voltage - v) * 100.0f / (dry_voltage - wet_voltage);
|
float p = (dry_voltage - v) * 100.0f / (dry_voltage - wet_voltage);
|
||||||
if (p < 0) p = 0;
|
if (p < 0) p = 0;
|
||||||
if (p > 100) p = 100;
|
if (p > 100) p = 100;
|
||||||
@@ -263,10 +300,10 @@ sensor:
|
|||||||
update_interval: 2s
|
update_interval: 2s
|
||||||
icon: "mdi:water-percent"
|
icon: "mdi:water-percent"
|
||||||
lambda: |-
|
lambda: |-
|
||||||
const float wet_voltage = 1.20;
|
float wet_voltage = id(hb4_wet_voltage);
|
||||||
const float dry_voltage = 2.70;
|
float dry_voltage = id(hb4_dry_voltage);
|
||||||
float v = id(b4_sensor4).state;
|
float v = id(b4_sensor4).state;
|
||||||
if (isnan(v)) return NAN;
|
if (isnan(v) || dry_voltage <= wet_voltage) return NAN;
|
||||||
float p = (dry_voltage - v) * 100.0f / (dry_voltage - wet_voltage);
|
float p = (dry_voltage - v) * 100.0f / (dry_voltage - wet_voltage);
|
||||||
if (p < 0) p = 0;
|
if (p < 0) p = 0;
|
||||||
if (p > 100) p = 100;
|
if (p > 100) p = 100;
|
||||||
|
|||||||
Reference in New Issue
Block a user