Skip to content

Commit 79e4c85

Browse files
bskjonbskjonKoenkk
authored
feat(add): 4512783/4512784 (#8650)
Co-authored-by: bskjon <[email protected]> Co-authored-by: Koen Kanters <[email protected]>
1 parent 4471082 commit 79e4c85

File tree

2 files changed

+563
-0
lines changed

2 files changed

+563
-0
lines changed

src/devices/namron.ts

+132
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import tz from '../converters/toZigbee';
55
import * as constants from '../lib/constants';
66
import * as exposes from '../lib/exposes';
77
import * as m from '../lib/modernExtend';
8+
import * as namron from '../lib/namron';
89
import * as reporting from '../lib/reporting';
910
import * as globalStore from '../lib/store';
1011
import * as tuya from '../lib/tuya';
@@ -1519,6 +1520,137 @@ const definitions: DefinitionWithExtend[] = [
15191520
description: 'Zigbee smart plug dimmer 150W',
15201521
extend: [m.light(), m.electricityMeter({cluster: 'electrical'})],
15211522
},
1523+
{
1524+
zigbeeModel: ['4512783', '4512784'],
1525+
model: '4512783/4512784',
1526+
vendor: 'Namron',
1527+
description: 'Zigbee edge thermostat',
1528+
fromZigbee: [
1529+
fz.thermostat,
1530+
namron.fromZigbee.namron_edge_thermostat_holiday_temp,
1531+
namron.fromZigbee.namron_edge_thermostat_vacation_date,
1532+
fz.namron_hvac_user_interface,
1533+
fz.metering,
1534+
fz.electrical_measurement,
1535+
],
1536+
toZigbee: [
1537+
tz.thermostat_local_temperature,
1538+
tz.thermostat_occupied_heating_setpoint,
1539+
tz.thermostat_unoccupied_heating_setpoint,
1540+
tz.namron_thermostat_child_lock,
1541+
tz.thermostat_control_sequence_of_operation,
1542+
tz.thermostat_programming_operation_mode,
1543+
tz.thermostat_temperature_display_mode,
1544+
tz.thermostat_local_temperature_calibration,
1545+
tz.thermostat_running_state,
1546+
tz.thermostat_running_mode,
1547+
namron.toZigbee.namron_edge_thermostat_holiday_temp,
1548+
namron.toZigbee.namron_edge_thermostat_vacation_date,
1549+
],
1550+
onEvent: async (type, data, device, options) => {
1551+
if (type === 'stop') {
1552+
try {
1553+
const key = 'time_sync_value';
1554+
clearInterval(globalStore.getValue(device, key));
1555+
globalStore.clearValue(device, key);
1556+
} catch {
1557+
/* Do nothing*/
1558+
}
1559+
}
1560+
if (!globalStore.hasValue(device, 'time_sync_value')) {
1561+
const hours24 = 1000 * 60 * 60 * 24;
1562+
const interval = setInterval(async () => {
1563+
try {
1564+
const endpoint = device.getEndpoint(1);
1565+
// Device does not asks for the time with binding, therefore we write the time every 24 hours
1566+
const time = new Date().getTime() / 1000;
1567+
await endpoint.write('hvacThermostat', {
1568+
[0x800b]: {
1569+
value: time,
1570+
type: Zcl.DataType.UINT32,
1571+
},
1572+
});
1573+
} catch {
1574+
/* Do nothing*/
1575+
}
1576+
}, hours24);
1577+
globalStore.putValue(device, 'time_sync_value', interval);
1578+
}
1579+
},
1580+
configure: async (device, coordinatorEndpoint, _logger) => {
1581+
const endpoint = device.getEndpoint(1);
1582+
const binds = [
1583+
'genBasic',
1584+
'genIdentify',
1585+
'genOnOff',
1586+
'hvacThermostat',
1587+
'hvacUserInterfaceCfg',
1588+
'msRelativeHumidity',
1589+
'seMetering',
1590+
'haElectricalMeasurement',
1591+
'msOccupancySensing',
1592+
];
1593+
await reporting.bind(endpoint, coordinatorEndpoint, binds);
1594+
1595+
await reporting.thermostatOccupiedHeatingSetpoint(endpoint, {min: 0, change: 50});
1596+
await reporting.thermostatTemperature(endpoint, {min: 0, change: 50});
1597+
await reporting.thermostatKeypadLockMode(endpoint);
1598+
1599+
// Initial read
1600+
await endpoint.read('hvacThermostat', [0x8000, 0x8001, 0x8002, 0x801e, 0x8004, 0x8006, 0x8005, 0x8029, 0x8022, 0x8023, 0x8024]);
1601+
1602+
device.powerSource = 'Mains (single phase)';
1603+
device.save();
1604+
},
1605+
extend: [
1606+
m.electricityMeter({voltage: false}),
1607+
m.onOff({powerOnBehavior: false}),
1608+
namron.edgeThermostat.windowOpenDetection(),
1609+
namron.edgeThermostat.antiFrost(),
1610+
namron.edgeThermostat.summerWinterSwitch(),
1611+
namron.edgeThermostat.vacationMode(),
1612+
namron.edgeThermostat.timeSync(),
1613+
namron.edgeThermostat.autoTime(),
1614+
namron.edgeThermostat.displayActiveBacklight(),
1615+
namron.edgeThermostat.displayAutoOff(),
1616+
namron.edgeThermostat.regulatorPercentage(),
1617+
namron.edgeThermostat.regulationMode(),
1618+
namron.edgeThermostat.sensorMode(),
1619+
namron.edgeThermostat.boostTime(),
1620+
namron.edgeThermostat.readOnly.boostTimeRemaining(),
1621+
namron.edgeThermostat.systemMode(),
1622+
namron.edgeThermostat.deviceTime(),
1623+
namron.edgeThermostat.readOnly.windowState(),
1624+
namron.edgeThermostat.readOnly.deviceFault(),
1625+
namron.edgeThermostat.readOnly.workDays(),
1626+
m.humidity(),
1627+
],
1628+
exposes: [
1629+
e
1630+
.climate()
1631+
.withLocalTemperature()
1632+
.withSetpoint('occupied_heating_setpoint', 15, 35, 0.5)
1633+
.withSystemMode(['off', 'auto', 'cool', 'heat'], ea.ALL)
1634+
.withLocalTemperatureCalibration(-3, 3, 0.1)
1635+
.withRunningState(['idle', 'heat']),
1636+
e.enum('temperature_display_mode', ea.ALL, ['celsius', 'fahrenheit']).withLabel('Temperature Unit').withDescription('Select Unit'),
1637+
e.enum('operating_mode', ea.ALL, ['Manual', 'ECO']).withDescription('Selected program for thermostat'),
1638+
e.binary('child_lock', ea.ALL, 'LOCK', 'UNLOCK').withDescription('Enables/disables physical input on the device'),
1639+
e
1640+
.numeric('holiday_temp_set', ea.ALL)
1641+
.withValueMin(5)
1642+
.withValueMax(35)
1643+
.withValueStep(0.5)
1644+
.withUnit('°C')
1645+
.withLabel('Vacation temperature')
1646+
.withDescription('Vacation temperature setpoint'),
1647+
e
1648+
.text('vacation_start_date', ea.ALL)
1649+
.withDescription('Start date')
1650+
.withDescription("Supports dates starting with day or year with '. - /'"),
1651+
e.text('vacation_end_date', ea.ALL).withDescription('End date').withDescription("Supports dates starting with day or year with '. - /'"),
1652+
],
1653+
},
15221654
];
15231655

15241656
export default definitions;

0 commit comments

Comments
 (0)