Skip to content

Instantly share code, notes, and snippets.

@Koenkk
Last active June 1, 2023 08:40
Show Gist options
  • Save Koenkk/34e60391471f8a6333176594dd80445d to your computer and use it in GitHub Desktop.
Save Koenkk/34e60391471f8a6333176594dd80445d to your computer and use it in GitHub Desktop.
const fz = require('zigbee-herdsman-converters/converters/fromZigbee');
const tz = require('zigbee-herdsman-converters/converters/toZigbee');
const exposes = require('zigbee-herdsman-converters/lib/exposes');
const reporting = require('zigbee-herdsman-converters/lib/reporting');
const extend = require('zigbee-herdsman-converters/lib/extend');
const utils = require('zigbee-herdsman-converters/lib/utils');
const ota = require('zigbee-herdsman-converters/lib/ota');
const tuya = require('zigbee-herdsman-converters/lib/tuya');
const e = exposes.presets;
const ea = exposes.access;
const definition = {
fingerprint: tuya.fingerprint('TS0601', ['_TZE200_lsanae15', '_TZE200_bkkmqmyo', '_TZE200_eaac7dkw']),
model: 'TS0601_din_1',
vendor: 'TuYa',
description: 'Zigbee DIN energy meter',
fromZigbee: [tuya.fzDataPoints],
toZigbee: [tuya.tzDataPoints],
configure: tuya.configureMagicPacket,
exposes: [tuya.exposes.switch(), e.ac_frequency(), e.energy(), e.power(), e.power_factor(), e.voltage(), e.current(),
exposes.numeric('produced_energy', exposes.access.STATE).withUnit('kWh').withDescription('Sum of produced energy'),],
meta: {
tuyaDatapoints: [
[1, 'energy', tuya.valueConverter.divideBy100],
[6, null, tuya.valueConverter.phaseA], // voltage and current
[16, 'state', tuya.valueConverter.onOff],
[103, 'power', tuya.valueConverter.raw],
[105, 'ac_frequency', tuya.valueConverter.divideBy100],
[111, 'power_factor', tuya.valueConverter.divideBy10],
// Ignored for now; we don't know what the values mean
[109, null, null], // reactive_power in VArh, ignored for now
[101, null, null], // total active power (translated from chinese) - same as energy dp 1??
[102, 'produced_energy', tuya.valueConverter.divideBy100],
[9, null, null], // Fault - we don't know the possible values here
[110, null, null], // total reactive power (translated from chinese) - value is 0.03kvar, we already have kvarh on dp 109
[17, null, null], // Alarm set1 - value seems garbage "AAAAAAAAAAAAAABkAAEOAACqAAAAAAAKAAAAAAAA"
[18, null, null], // 18 - Alarm set2 - value seems garbage "AAUAZAAFAB4APAAAAAAAAAA="
],
},
whiteLabel: [{vendor: 'Hiking', model: 'DDS238-2'}, {vendor: 'TuYa', model: 'RC-MCB'}],
};
module.exports = definition;
@Matriciel
Copy link

@Koenkk thank for your response. For other point, i need to wait net release for all exposes point with _TZE200_lsanae15 ?

@gericho
Copy link

gericho commented Oct 18, 2022

Is there a possibility to modify this timer to have a return every 30 seconds, as on the original model?

please be aware my comment can be off topic

I am on the same boat, Home asisstant DB is growing so fast with 3 tuya power-meters, querying the DB shows a consistent flooding so at the moment I excluded some entities related to this Power meter. I'm searching if there is an HA recorder setting to get less granularity only on some entities, still no luck. Maybe someone can help.

@kirillec
Copy link

@gericho, Use the addon MariaDB there everything is done very simply
Here are all the details:

https://www.home-assistant.io/integrations/recorder/

@gericho
Copy link

gericho commented Oct 19, 2022

Use the addon MariaDB there everything is done very simply

Thank you for the advice, I tiried already days ago, I'm on a raspberry Pi3, Maria DB literally killed the system on a 64bit Hassio, I downgraded yesterday to 32bit Hassio using a full backup, I'll try if works better. BTW 32bit on this machine is WAY faster, 30% ram saved, never used swap, the system is fresh like new again. I'll try mariaDB on 32bit, but I'm worried SD cards (I'm using a sandisk max endurance) are no longer a viable solution with latest Hassio releases, I see all people switching to SSD, at that point better to point on a faster machine. I STILL think Home assistant developers have to take in consideration to customize granularity in recorder by entity. A sensor that pushes 10+ entities to the network (if you use original hub and app) every 10 seconds, is just sad, starting from TuYa decision to flood the network in general, no doubt.

@Koenkk
Copy link
Author

Koenkk commented Oct 19, 2022

@raslr6
Copy link

raslr6 commented Oct 19, 2022

Hi, thanks for your great job, but i have a error with the code.

[18:09:33] INFO: Preparing to start...
[18:09:33] INFO: Socat not enabled
[18:09:34] INFO: Starting Zigbee2MQTT...
/app/dist/util/externally-loaded.js:20
exposes: [tuya.exposes.switch(), e.ac_frequency(), e.energy(), e.power(), e.power_factor(), e.voltage(), e.current(),
^
TypeError: tuya.exposes.switch is not a function
at /app/dist/util/externally-loaded.js:20:34
at Script.runInContext (node:vm:139:12)
at Script.runInNewContext (node:vm:144:17)
at Object.runInNewContext (node:vm:298:38)
at loadModuleFromText (/app/lib/util/utils.ts:148:8)
at loadModuleFromFile (/app/lib/util/utils.ts:155:12)
at Object.getExternalConvertersDefinitions (/app/lib/util/utils.ts:165:25)
at getExternalConvertersDefinitions.next ()
at new ExternalConverters (/app/lib/extension/externalConverters.ts:12:20)
at new Controller (/app/lib/controller.ts:84:58)

what can i do?
thanks

@Koenkk
Copy link
Author

Koenkk commented Oct 20, 2022

@raslr6
Copy link

raslr6 commented Oct 20, 2022

@Koenkk How can I look at it and if I don't have it, how is it updated, I don't have much skill even with all this, i have home assistant add-on thanks

@raslr6
Copy link

raslr6 commented Oct 20, 2022

@Koenkk I'm sorry, I didn't notice that edge was another version, it's already working, thank you very much

@Koenkk
Copy link
Author

Koenkk commented Oct 20, 2022

To be sure you are on the latest edge, uninstall and install the addon

@ArGinTTT
Copy link

Hello gentlemans,

Long time din't hear us. I hope you are doing fine.
I think I need your support again :| Apparently I buyed a second DDS238-2 zigbee, but apparently it's a different manufacture: TZE200_byzdayie, and again I can't see in zigbee2mqtt "produced energy" like in manufacture TZE200_bkkmqmyo. Can you give me some hints how to do it also for this device? It will be nice if I would get the same parameters for both of them, like in attached picture.

Thank you!

image

@ArGinTTT
Copy link

ArGinTTT commented Jun 1, 2023

Hi,
I also observed that in TZE200_byzdayie the power is not give negative values, like power from TZE200_bkkmqmyo. Ca you please support me?
Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment