irrigation/src/ha-constants.js

68 lines
1.6 KiB
JavaScript

const PUMP = {tmpl:'input_boolean.%r%',hass_function:'updateEntity'}
const RUNNER = {
countdown:'next_trigger',
nextDT:'next_trigger_dt',
nextName:'next_schedule_name',
running:'running_names',
queue:'queue_names'
}
const ZONE = {
enabled:{
tmpl: 'input_boolean.%r%_schedule_enabled',
hass_function:'updateEntity',
schedule : true,
path:'settings',
out_value_function:onoff,
in_value_function:tf
},
delta: {
tmpl:'input_select.%r%_schedule_delta',
schedule : true,
path:'settings.timing',
hass_function:'setSelect',
out_value_function: (value,deltas) => deltas[value.toString()],
in_value_function: (str,deltas) => Object.entries(deltas).find(delta => delta[1] === str)[0]
},
hour: {
tmpl: 'input_number.%r%_schedule_base_hour',
path:'settings.timing',
schedule : true
},
minute: {
tmpl:'input_number.%r%_schedule_base_minute',
path:'settings.timing',
schedule : true
},
nextDT: {
tmpl:'%r%_schedule_next_dt',
hass_function:'setVariable',
schedule : true,
},
countdown: {
tmpl: '%r%_schedule_countdown',
hass_function:'setVariable',
schedule: true
},
duration:{
tmpl: 'input_number.%r%_duration',
path:'settings'
},
state:{
tmpl: 'input_boolean.%r%_state',
hass_function:'updateEntity',
in_function: function (zone,value) {
// console.log(zone.id,'ha requested state change', value)
this.zoneOn(zone,value)
},
in_no_state_change: true
},
}
export { ZONE, PUMP, RUNNER}
function onoff(bol) { return bol ? 'on':'off'}
function tf(onoff) { return (onoff === 'on') ? true:false}