formtapez / ZigUP

CC2530 based multi-purpose ZigBee Relais, Switch, Sensor and Router
314 stars 73 forks source link

Added support for 16 ds18b20 temperature sensors #9

Closed prelude0000 closed 4 years ago

prelude0000 commented 4 years ago

Added support for 16 parallelly connected ds18b20.

prelude0000 commented 4 years ago

zigbee2mqtt output after pathing "fromZigbee.js" file.

ZigUP_parse: {
    cid: 'genOnOff',
    type: ['attReport', 'readRsp'],
    convert: (model, msg, publish, options) => {
        const lookup = {
            '0': 'timer',
            '1': 'key',
            '2': 'dig-in',
        };
        const ds18b20_id = msg.data.data['41368'].split(':')[0];
        const ds18b20_value = precisionRound(msg.data.data['41368'].split(':')[1], 2);

        return {
            state: msg.data.data['onOff'] === 1 ? 'ON' : 'OFF',
            cpu_temperature: precisionRound(msg.data.data['41361'], 2),
            external_temperature: precisionRound(msg.data.data['41362'], 1),
            external_humidity: precisionRound(msg.data.data['41363'], 1),
            s0_counts: msg.data.data['41364'],
            adc_volt: precisionRound(msg.data.data['41365'], 3),
            dig_input: msg.data.data['41366'],
            reason: lookup[msg.data.data['41367']],
            [`${ds18b20_id}`]: ds18b20_value,
        };
    },
},

zigbee2mqtt | zigbee2mqtt:info 8/23/2019, 7:27:37 PM MQTT publish: topic 'zigbee2mqtt/45_zigup_ilmastointi', payload '{"state":"OFF","cpu_temperature":24.26,"external_temperature":21.3,"external_humidity":null,"s0_counts":0,"adc_volt":32.354,"dig_input":1,"reason":"timer","linkquality":26,"B1000004D01FBF28":21.31,"82000004D0977C28":21.25,"4D000004D0DC8328":21.5}'

formtapez commented 4 years ago

I tested your code today with up to 4 DS18B20 sensors. Detection and temperature readings are working fine (on UART), but the first report via ZigBee repeatable locks up my Zigbee2MQTT coordinator. It throws AM - error: Failed to reenable joining and then locks up. No communication with any of my other devices is possible then anymore. Didn't you had similar behaviour? Maybe something is wrong with that string datatype, or the whole buffer is getting too big.

prelude0000 commented 4 years ago

Good finding, let's find root couse for it.

im using zigbee2mqtt@1.5.1 version and i haven faced any problem with pairing except when domoticz is conneced in same time. in that case ZigUP just not appear zigbee2mqtt device list but ihave think that reason is Domoticz where i still creating a plugin. When i disconnec (stopping container) Domotics from mosquitto then pairing works fine and after that it's working od regardless is domoticz connected or not. Currently i testing it with 3 sensor but i will make 16 sensor setup close days. I tryed it in some pointand it was fine but better that i recheck it.

I also parsed my log files and cannot see anything similar error message.

Could you take log with zigbee sniffer when ZigUP doing paring? I do same so we can compare if there is some differece.

formtapez commented 4 years ago

I just switched my coordinator from CC2530 to CC2531-Stick and now it doesnt crash anymore. Temperature-String is shown correctly, but with no sensors ("\x05Empty") this shows instead:

zigbee2mqtt:info 8/31/2019, 11:44:40 AM MQTT publish: topic 'home/DevBoard', payload '{"state":"OFF","cpu_temperature":18.42,"external_temperature":null,"external_humidity":null,"s0_counts":0,"adc_volt":2.18,"dig_input":1,"reason":"timer","test":"mpty\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000�Q\u0018\u0000\u0000\u0000\u0000�\u0019\u0000\u0000\u0000\u0000\u0000\u0000\u0010\u001a\u0000\u0000\u0000\u0000\u0000\u0000�\u0019\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0006\u0012\b\b\b$\u0003\u0000\u0000\u0000\u0006\u000e\u001f\u0014\u001f\u0000\u0000\u001a\u001f ","linkquality":42}'

formtapez commented 4 years ago

Thanks for your good work and investigations. There was another small issue with wrong empty-stringlength which i just fixed in a commit afterwards. I also changed your example for the zigbee2mqtt converter, so it doesnt fail on devices with old firmware (without that new data field). I'll open a pullrequest there in the next days, but that usually takes very long into the next release. I temporarily included that files in "/zigbee-shepherd-converters/". If you see something wrong, please let me know.

https://github.com/Koenkk/zigbee-shepherd-converters/pull/590