logo elektroda
logo elektroda
X
logo elektroda

Integrating ESP8266 with Tasmota into PG107 Alarm System for Home Assistant

kbogdan87 681 8
ADVERTISEMENT
  • #1 21499943
    kbogdan87
    Level 3  
    Hello everyone! I have a pg107 alarm system with a cb3s Wi-Fi module, this module has problems connecting to Wi-Fi. I decided to replace it with an esp8266 with tasmota firmware. PG107 has an allwiner mcu with a tuya mcu protocol, I recognized all the functions and even created rules for time and Wi-Fi status, but I don't know how to coordinate the functions with Tasmota and home assistant or best variant for me its connect esp8266 with smart life. Also i read dump from cb3s.

    Link

    Electronic board with various components.
    Control panel display with SOS button and security functions.

    And i found this informaition maybe it help
    Spoiler:
    {
      "result": {
        "model": "{\"modelId\":\"000004mhbz\",\"services\":[{\"actions\":[],\"code\":\"\",\"description\":\"\",\"events\":[],\"name\":\"默认服务\",\"properties\":[
    {\"abilityId\":1,\"accessMode\":\"rw\",\"code\":\"master_mode\",\"description\":\"disarmed撤防 arm布防 home在家 sos紧急\",\"extensions\":{\"iconName\":\"icon-dp_mode\"},\"name\":\"工作模式\",\"typeSpec\":{\"range\":[\"disarmed\",\"arm\",\"home\",\"sos\"],\"type\":\"enum\",\"typeDefaultValue\":\"disarmed\"}},
    {\"abilityId\":2,\"accessMode\":\"rw\",\"code\":\"delay_set\",\"description\":\"\",\"extensions\":{\"iconName\":\"icon-dp_time3\"},\"name\":\"退出延时\",\"typeSpec\":{\"max\":1000,\"min\":0,\"scale\":0,\"step\":1,\"type\":\"value\",\"typeDefaultValue\":0,\"unit\":\"s\"}},
    {\"abilityId\":3,\"accessMode\":\"rw\",\"code\":\"alarm_time\",\"description\":\"\",\"extensions\":{\"iconName\":\"icon-dp_time3\"},\"name\":\"警号鸣响时间\",\"typeSpec\":{\"max\":1000,\"min\":0,\"scale\":0,\"step\":1,\"type\":\"value\",\"typeDefaultValue\":0,\"unit\":\"min\"}},
    {\"abilityId\":4,\"accessMode\":\"rw\",\"code\":\"switch_alarm_sound\",\"description\":\"\",\"extensions\":{\"iconName\":\"icon-dp_power3\"},\"name\":\"布防提示音\",\"typeSpec\":{\"type\":\"bool\",\"typeDefaultValue\":false}},
    {\"abilityId\":6,\"accessMode\":\"rw\",\"code\":\"switch_alarm_light\",\"description\":\"\",\"extensions\":{\"iconName\":\"icon-baojing\",\"attribute\":\"128\"},\"name\":\"报警提示音\",\"typeSpec\":{\"type\":\"bool\",\"typeDefaultValue\":false}},
    {\"abilityId\":10,\"accessMode\":\"rw\",\"code\":\"switch_mode_sound\",\"description\":\"\",\"extensions\":{\"iconName\":\"icon-power\",\"attribute\":\"1152\"},\"name\":\"工作模式提示音开关\",\"typeSpec\":{\"type\":\"bool\",\"typeDefaultValue\":false}},
    {\"abilityId\":12,\"accessMode\":\"rw\",\"code\":\"switch_kb_sound\",\"description\":\"\",\"extensions\":{\"iconName\":\"icon-power\",\"attribute\":\"128\"},\"name\":\"布撤防短信\",\"typeSpec\":{\"type\":\"bool\",\"typeDefaultValue\":false}},
    {\"abilityId\":13,\"accessMode\":\"rw\",\"code\":\"switch_kb_light\",\"description\":\"\",\"extensions\":{\"iconName\":\"icon-dp_power2\",\"attribute\":\"128\"},\"name\":\"键盘背光\",\"typeSpec\":{\"type\":\"bool\",\"typeDefaultValue\":false}},
    {\"abilityId\":24,\"accessMode\":\"rw\",\"code\":\"zone_attribute\",\"description\":\"0-留守布防有效;1-外出布防有效;2-24小时有效;3-关闭;4-门铃;5-24小时无声;6-留守布防有效(无延时);7-外出布防有效(无延时)\",\"extensions\":{\"iconName\":\"icon-air_quality\"},\"name\":\"防区属性\",\"typeSpec\":{\"range\":[\"MODE_HOME_ARM\",\"MODE_ARM\",\"MODE_24\",\"MODE_OFF\",\"MODE_DOORBELL\",\"MODE_24_SILENT\",\"HOME_ARM_NO_DELAY\",\"ARM_NO_DELAY\"],\"type\":\"enum\",\"typeDefaultValue\":\"MODE_HOME_ARM\"}},
    {\"abilityId\":25,\"accessMode\":\"rw\",\"code\":\"muffling\",\"description\":\"\",\"extensions\":{\"iconName\":\"icon-Mute\"},\"name\":\"消音\",\"typeSpec\":{\"type\":\"bool\",\"typeDefaultValue\":false}},
    {\"abilityId\":26,\"accessMode\":\"rw\",\"code\":\"alarm_message\",\"description\":\"\\t\\n告警消息\",\"extensions\":{\"iconName\":\"icon-baojing\",\"attribute\":\"128\"},\"name\":\"告警信息\",\"typeSpec\":{\"maxlen\":128,\"type\":\"raw\"}},
    {\"abilityId\":27,\"accessMode\":\"rw\",\"code\":\"switch_alarm_propel\",\"description\":\"\",\"extensions\":{\"iconName\":\"icon-baojing\",\"attribute\":\"128\"},\"name\":\"告警推送\",\"typeSpec\":{\"type\":\"bool\",\"typeDefaultValue\":false}},
    {\"abilityId\":28,\"accessMode\":\"rw\",\"code\":\"alarm_delay_time\",\"description\":\"\",\"extensions\":{\"iconName\":\"icon-baojing\"},\"name\":\"进入延时\",\"typeSpec\":
    {\"max\":1000,\"min\":0,\"scale\":0,\"step\":1,\"type\":\"value\",\"typeDefaultValue\":0,\"unit\":\"s\"}},{\"abilityId\":32,\"accessMode\":\"rw\",\"code\":\"master_state\",\"description\":\"\",\"extensions\":{\"iconName\":\"icon-zhuangtai\"},\"name\":\"主机状态\",\"typeSpec\":{\"range\":[\"normal\",\"alarm\"],\"type\":\"enum\",\"typeDefaultValue\":\"normal\"}},
    {\"abilityId\":34,\"accessMode\":\"rw\",\"code\":\"factory_reset\",\"description\":\"\",\"extensions\":{\"iconName\":\"icon-setting\",\"attribute\":\"1024\"},\"name\":\"恢复出厂设置\",\"typeSpec\":{\"type\":\"bool\",\"typeDefaultValue\":false}},
    {\"abilityId\":36,\"accessMode\":\"rw\",\"code\":\"sub_class\",\"description\":\"0-遥控器 1-探测器 2-插座\",\"extensions\":{\"iconName\":\"icon-dp_mode\"},\"name\":\"子设备品类\",\"typeSpec\":{\"range\":[\"remote_controller\",\"detector\",\"socket\"],\"type\":\"enum\",\"typeDefaultValue\":\"remote_controller\"}},
    {\"abilityId\":37,\"accessMode\":\"rw\",\"code\":\"sub_type\",\"description\":\"0-系统警情;1-主门报警;2-大厅报警;3-求救报警;4-卧室报警;5-窗户报警;6-阳台报警;7-周界报警;8-烟雾报警;9-燃气泄漏;10-一氧化碳;11-漏水报警。\",\"extensions\":{\"iconName\":\"icon-dp_mode\"},\"name\":\"设备类型\",\"typeSpec\":{\"range\":[\"OTHER\",\"DOOR\",\"PIR\",\"SOS\",\"ROOM\",\"WINDOW\",\"BALCONY\",\"FENCE\",\"SMOKE\",\"GAS\",\"CO\",\"WATER\"],\"type\":\"enum\",\"typeDefaultValue\":\"OTHER\"}},
    {\"abilityId\":38,\"accessMode\":\"rw\",\"code\":\"sub_admin\",\"description\":\"子设备\",\"extensions\":{\"iconName\":\"icon-dp_mode\"},\"name\":\"子设备管理\",\"typeSpec\":{\"maxlen\":128,\"type\":\"raw\"}},
    {\"abilityId\":39,\"accessMode\":\"ro\",\"code\":\"sub_state\",\"description\":\"\",\"extensions\":{\"iconName\":\"icon-zhuangtai\"},\"name\":\"子设备状态\",\"typeSpec\":{\"range\":[\"normal\",\"alarm\",\"fault\",\"others\"],\"type\":\"enum\",\"typeDefaultValue\":\"normal\"}},
    {\"abilityId\":45,\"accessMode\":\"rw\",\"code\":\"alarm_call_unit\",\"description\":\"独立报警电话短信开关\",\"extensions\":{\"iconName\":\"icon-baojing\",\"attribute\":\"128\"},\"name\":\"报警电话号码\",\"typeSpec\":{\"maxlen\":128,\"type\":\"raw\"}},
    {\"abilityId\":101,\"accessMode\":\"ro\",\"code\":\"PowerEvent\",\"description\":\"0正常1主电源断开2电池电量不足\",\"name\":\"电源状态信息\",\"typeSpec\":{\"range\":[\"normal\",\"powerDisconnect\",\"BatteryIsLow\"],\"type\":\"enum\",\"typeDefaultValue\":\"normal\"}},
    {\"abilityId\":103,\"accessMode\":\"ro\",\"code\":\"zone_number\",\"description\":\"推送指令报警类型+防区名称\",\"name\":\"防区号\",\"typeSpec\":{\"maxlen\":128,\"type\":\"raw\"}},
    {\"abilityId\":104,\"accessMode\":\"ro\",\"code\":\"OtherEvent\",\"description\":\"\",\"name\":\"其他事件\",\"typeSpec\":{\"range\":[\"Normal\",\"TAMPER\"],\"type\":\"enum\",\"typeDefaultValue\":\"Normal\"}}]}]}"
      },
      "success": true,
      "t": 1689716723175,
      "tid": "65f1b0f925b411ee871736843e81b476"
    }
  • ADVERTISEMENT
  • #2 21500635
    p.kaczmarek2
    Moderator Smart Home
    Are WiFi connection problems present on OBK as well, or only Tuya firmware?

    What is your current Tasmota setup?
    Helpful post? Buy me a coffee.
  • ADVERTISEMENT
  • #3 21500844
    kbogdan87
    Level 3  
    I know that all pg107 devices have a wifi disconnecting problem, i dont understand how recognize where the problem.
    Present settings are: configuration of module tuyamcu(54), tuya tx-gpio1 tuyarx gpio3,
    Rule1 ON Wifi#Connected DO SerialSend5 55AA00030001030306 ENDON
    Rule1 ON Wifi#Disconnected DO SerialSend5 55AA00030001020205 ENDON
    Rule1 ON Mqtt#Connected DO SerialSend5 55AA00030001040407 ENDON
    Rule1 ON Mqtt#Disconnected DO SerialSend5 55AA00030001020205 ENDON
    Rule1 ON Wifi#State<=3 DO SerialSend5 55AA00030001000003 ENDON
    Rule1 ON Wifi#State>=8 DO SerialSend5 55AA0003000108080B ENDON
    Rule1 ON System#Boot DO SerialSend5 55AA0003000107070A ENDON
    Rule1 ON Power1#State=0 DO SerialSend5 55AA00030001050508 ENDON
    Rule1 1

    Backlog
      Timezone +0;
      TimeDST 0,3,10,3,0;
      Rule2 ON Time#Initialized DO Backlog
        Year = %year% - 2000 + 256;
        Month = %month%;
        Day = %day%;
        Hour = (%hour% + 3) %% 24;
        Minute = %minute%;
        Second = %second%;
        SerialSend5 "55AA001C0008$(Year,HEX:2)$(Month,HEX:2)$(Day,HEX:2)$(Hour,HEX:2)$(Minute,HEX:2)$(Second,HEX:2)05"
      ENDON

    I can receive messages and can transmit it.

    Added after 1 [hours] 5 [minutes]:

    >>21500635 OBK you mean openbeken project? https://github.com/openshwprojects/OpenBK7231T_App
  • ADVERTISEMENT
  • #4 21508814
    p.kaczmarek2
    Moderator Smart Home
    Did you see https://github.com/tasmota/docs-7.1/blob/master/TuyaMCU.md?


    Still, it would be easier to do it with OBK on CB3S
    Helpful post? Buy me a coffee.
  • #5 21509461
    kbogdan87
    Level 3  
    >>21508814
    I read this information, but I don't understand how to apply it to my device. I'm not against any option, as long as it works! And if I stay on cb3s how to fix wifi problems?
  • #6 21520367
    kbogdan87
    Level 3  
    p.kaczmarek2 wrote:
    Did you see https://github.com/tasmota/docs-7.1/blob/master/TuyaMCU.md?


    Still, it would be easier to do it with OBK on CB3S

    Are you familiar with the xdrv_tuyamcu_v2 file in the tasmota repository? I don't understand how to connect it to my device's firmware!? This file contains a more complete tuyaMcu protocol. https://github.com/arendst/Tasmota/blob/devel...ta/tasmota_xdrv_driver/xdrv_16_tuyamcu_v2.ino
    and what about my dump from cb3s?
    is it possible to connect to tuya cloud with tasmota firmware?
  • ADVERTISEMENT
  • #7 21520394
    p.kaczmarek2
    Moderator Smart Home
    Your questions are a bit broad, it would be a bit easier for me if you were more specific, but currently you have two options.
    1. use CB3S with OpenBeken, use TuyaMCU guide: https://www.elektroda.com/rtvforum/topic4038151.html
    2. Keep using ESP, and configure TuyaMCU on Tasmota.
    You said:
    Quote:

    but I don't know how to coordinate the functions with Tasmota and home assistant

    Which specific function would you like to set from Tasmota?
    I think you should be able to use:
    Screenshot of documentation describing the TuyaMCU command for mapping Tasmota components to Tuya device dpId.

    Added after 2 [minutes]:

    Btw: Your TuyaMCU code link is invalid
    Helpful post? Buy me a coffee.
  • #8 21520420
    kbogdan87
    Level 3  
    >>21520394 I want create enum function for dpid 1(arm, disarm, home, sos modes) but tasmota doesn't save map, for example tuyamcu 21,1, after changing this setting tasmota returns fnid to default! Maybe it is not necessarily, i think i can use mqtt to manage alarm system. I would like to use tuya cloud, do you have any idea how to fix cloud or wifi problems?
    I sniff messages from mcu and dont understand why a mcu request mac address even it receives mac, this could be the root of the problem.
    When cb3s was connected mcu requested weather information, with esp this does not happen.
    https://github.com/arendst/Tasmota/blob/devel...ta/tasmota_xdrv_driver/xdrv_16_tuyamcu_v2.ino
  • #9 21520429
    p.kaczmarek2
    Moderator Smart Home
    It would be very easy to handle dpid enumeration in OpenBeken, but if you want to use Tasmota, try creating separate rules per enum value, something like:
    
    
    Rule2 + ON TuyaReceived#Data=55AA00070005650400010075 DO Var2 sC3; ENDON
    

    The syntax may be wrong. I've taken it from there:
    https://gist.github.com/markus-li/ff407c891834a8e2670268ddd52b8330
    but TuyaReceived should help with triggering events on any TuyaMCU packet. What do you think?
    Helpful post? Buy me a coffee.

Topic summary

The discussion focuses on integrating an ESP8266 module flashed with Tasmota firmware into a PG107 alarm system, replacing the original CB3S Wi-Fi module which suffers from Wi-Fi connectivity issues. The PG107 uses an Allwinner MCU communicating via the Tuya MCU protocol. The user has configured Tasmota with the TuyaMCU module and created rules to handle Wi-Fi and MQTT connection states, but faces challenges coordinating device functions, especially enumerating DPIDs for alarm modes (arm, disarm, home, SOS). The user also seeks to connect the ESP8266 to the Tuya cloud and replicate CB3S functionality, including weather data requests. Suggestions include using the xdrv_tuyamcu_v2 driver in Tasmota for a more complete Tuya MCU protocol implementation and managing device states via MQTT or TuyaReceived events with custom rules. Alternatives discussed are using OpenBeken firmware on the CB3S module for better stability and easier DPID handling. The user notes that Tasmota resets certain TuyaMCU settings and suspects MCU requests for MAC address and weather data may be linked to connectivity problems. References to Tasmota documentation and community guides are provided for further configuration details.
Summary generated by the language model.
ADVERTISEMENT