GithubHelp home page GithubHelp logo

blog's Introduction

Main projects

  1. go2rtc - Ultimate camera streaming application

    Golang, RTP, SRTP, RTSP, SDP, RTMP, WebRTC, HomeKit, fMP4, MSE, MJPEG, HLS, H264, ONVIF backchannel, REST, WebSocket, STUN, TURN, mDNS, Docker, FFmpeg, Ngrok
  2. SonoffLAN - Control Sonoff Devices with eWeLink (original) firmware over LAN and/or Cloud from Home Assistant

    Python, REST, WebSocket, mDNS, RF433, eWeLink API
  3. XiaomiGateway3 - Control Zigbee, BLE and Mesh devices from Home Assistant with Xiaomi Gateway 3 on original firmware

    Python, bash, Telnet, REST, MQTT, miIO, MIoT, Bluetooth Mesh, Bluetooth BLE, MiBeacon, Silicon Labs EFR32, Zigbee EZSP, ZHA, zigbee2mqtt
  4. WebRTC Camera - View an camera RTSP-stream in real time (without any delay) using WebRTC technology

    Python, golang, RTSP, WebRTC, MSE, STUN, TURN, Chromecast
  5. HassWP - Portable version of Home Assistant for Windows (no need to install)

    Windows batch scripts, Python Virtual Environments

Other projects

  1. DashCast - Cast any site from Home Assistant to Chromecast
  2. Dataplicity - Public HTTPS access to Home Assistant with Dataplicity service
  3. StreamAssist - Turn almost any camera and almost any speaker into a local voice assistant
  4. PythonScriptsPro - Advanced version of python scripts for Home Assistant without limits
  5. Ergomotion Smart Beds - Control Ergomotion Smart Beds via Bluetooth module from Home Assistant
  6. Jura Coffee Machines - Control Jura Coffee Machines via Bluetooth module from Home Assistant
  7. Hass Diagnostics - Diagnostics entities for Home Assistant
  8. SSHCommand - Run SSH commands on remote host from Home Assistant
  9. OpenmiIO - Daemon app for Xiaomi Gateways
    Golang, MIPS, ARM, MQTT, miIO, serial, Silicon Labs EFR32, Lua, JSON-RPC

Russian projects

  1. YandexStation - Управление Яндекс.Станцией и другими колонками с Алисой из Home Assistant

    Python, REST, WebSocket, mDNS, TTS, NLU, Audio streaming, DLNA
  2. YandexDialogs - Управление Home Assistant через Яндекс.Диалоги
  3. MorphNumbers - Компонент Home Assistant для работы с числительными в Jinja2
  4. GyverLamp - Home Assistant компонент для интеграции лампы Гайвера на оригинальной прошивке

Contacts

Links

Hardware

Task Device Arch
for live MacBook Pro M1 mac arm64 + amd64
for dev Parallels Desktop win arm64 + amd64
home server Intel Nuc 10 i3 linux amd64
test server Raspberry Pi 3 linux arm

My personal thanks to JetBrains for great software and license for open source.

Donation

ЮMoney (если вы в России)

BTC: bc1qd826y7z7t3k5rfk2vvuzsprmep4uncq0ux2dya
ETH: 0xC1b61c51a66bAD79C71137D47F3e1789d9fB5985
TON: UQAT3xw0_edgJeEvv3HwEcs8I61TcqaKzOtADeR1ksdAUgl9
TRC20: TVnuJ5g5qz9F2UncCWV3wLch7ZkJL6Hj95

AlexxIT

blog's People

Contributors

alexxit avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

verdugojona89

blog's Issues

Recent Sonoff Integration Issues

My HA installation is receiving a persistent notification to reconfigure the Sonoff integration. The log shows that the password is incorrect. I have verified the account password in eWeLink and changed it in both the eWeLink app and in HA.
There is also this error in the log on restart of HA:

Logger: homeassistant.components.number
Source: components/number/init.py:220
Integration: Number (documentation, issues)
First occurred: 9:39:12 AM (3 occurrences)
Last logged: 9:39:12 AM

custom_components.sonoff.number::XNumber is overriding deprecated methods on an instance of NumberEntity, this is not valid and will be unsupported from Home Assistant 2022.10. Please report it to the custom component author.
custom_components.sonoff.number::XPulseWidth is overriding deprecated methods on an instance of NumberEntity, this is not valid and will be unsupported from Home Assistant 2022.10. Please report it to the custom component author.

go2rtc config

I have go2rtc and frigate integrations in Home Assistant.
I have a go2rtc.yaml config file for my camera streams and a go2rtc section in my frigate.yml file, also for go2rtc streams.
Is it necessary to have duplicated stream entries.
What exactly do the two sets of streams actually do?

Xiaomi Multimode Gateway 2

The new Xiaomi Multimode Gateway is on sale now.

Github

There are many names for the old and new versions on the Internet:

  1. Xiaomi Hub, Xiaomi Mijia Smart Multi-Mode Gateway, Xiaomi Smart Home Hub, Xiaomi Gateway 3, ZNDMWG03LM, ZNDMWG02LM, mgl03
  2. Xiaomi Hub 2, Xiaomi Mijia Smart Multi-Mode Gateway 2, Xiaomi Smart Home Hub 2, DMWG03LM, ZNDMWG04LM

The main pros compared to the previous version are:

  • new hardware: Dual-Core ARM 1GHz, 128MB DDR3 (nice)
  • more advanced zigbee chip of the same series (although the old chip was great too)
  • new bluetooth chip (don't know anything about it)
  • Dual-Band Wi-Fi (although the old 2.4GHz was stable as well)
  • Ethernet (for those who like wires)
  • USB Type-C (it's future)

It has telnet access, so theoretically could be supported in the Xiaomi Gateway 3 integration.

Comparsion table

Param Xiaomi Multimode Gateway Aqara Hub E1 Xiaomi Multimode Gateway 2 Aqara Camera G3
China model ZNDMWG03LM ZHWG16LM DMWG03LM ZNSXJ13LM
Euro model ZNDMWG02LM HE1-G01 ZNDMWG04LM CH-H03
SoC RTL8197F SSD212 SSD222D SSC339G
CPU MIPS-EL 660MHz 2 x ARM Cortex-A7 800MHz 2 x ARM Cortex-A7 1GHz 2 x ARM Cortex-A7 1.2GHz
RAM 64MB 64MB DDR2 128MB DDR3 128MB ??
Zigbee EFR32MG1B EFR32MG21 EFR32MG21 EFR21MG??
Bluetooth MHCB03P --- TLSR8236 ---
Wi-Fi 2.4GHz 2.4GHz SSW105 Dual-band Dual-band
Power Micro USB USB USB Type-C USB Type-C
Other BLE/Mesh no BLE/Mesh, Ethernet IR, Hardware gestures and face recognition

Useful links

v3.0-alpha.1

После обновления все zigbee устройства ушли в оффлайн по версии GateWay.
Главное, что шлюз больше не переподключает устройства (тут же 2 шлюз цепляет устройства штатно).
BLE устройства работают.

Issue with RTSP streaming of x265 or hevc_nvenc encoded file with opus audio: Only audio for WebRTC played and only the first picture for MSE shown.

Dear distinguish team,

I am writing to seek your assistance with a technical issue I am experiencing while testing the stream of an H.265 + opus file on Safari. I have already allowed WebRTC h265 in "Experimental Features" and tried H.264 streaming, which works well using the same settings in the go2rtc.yaml and ffmpeg commands for streaming.
To test the h.265 file, I used a file from one of the Apple Xcode open-source projects I work with, but the result was no audio, no video played for WebRTC, and only the first frame opened for MSE. I have included the details of the test below:

rtsp stream:
% ./ffmpeg -re -stream_loop -1 -i puppets_with_greenbg_hevc_nvenc_opus.mp4 -c copy -f rtsp rtsp://localhost:8554/stream1

go2rtc.yaml:

streams:
  stream1: ""

info: http://127.0.0.1:1984/api/streams?src=stream1:

{
  "producers": [
    {},
    {
      "type": "RTSP source",
      "url": "rtsp://localhost:8554/stream1",
      "remote_addr": "[::1]:65513",
      "user_agent": "Lavf59.27.100",
      "medias": [
        "video, sendonly, 96 H265/90000",
        "audio, sendonly, 97 OPUS/48000/2"
      ],
      "tracks": [
        "96 H265/90000, sinks=1",
        "97 OPUS/48000/2, sinks=1"
      ],
      "recv": 6700364
    }
  ],
  "consumers": [
    {
      "type": "WebRTC client",
      "remote_addr": "udp4 prflx 192.168.2.10:60248 related :0",
      "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.3 Safari/605.1.15",
      "send": 2613086
    }
  ]
}

Since there is no opus, I transcoded this file to an mp4 following your recommendations using libx265 and hevc_nvenc. However, using a standard FFmpeg build, I could not find a high profile for libx265 and hevc_nvenc and libx265. Could this be the problem? The result was the same for this file's libx265 and hevc_nvenc versions. In addition, audio only played for WebRTC, and only a single frame was shown with no sound for the MSE stream.
Please provide me with some guidance on what I might be doing wrong.
Thank you for your attention to this matter.

Thank you in advance!

Go2rtc v1.5.0 release

Please, don't create issues in this repository. Goto go2rtc project.

Exec Pipe

Exec source now support receiving frames using pipe transport (stdout). Useful for:

read more

ONVIF Client

New webpage for ONVIF protocol helps you to find local cameras:

image

And get their capabilities:

image

read more

ONVIF Server

Support simple ONVIF server for Home Assistant:

image

MJPEG after FFmpeg

RTSP transport puts restrictions on MJPEG format. So starting from this version:

  • MJPEG after FFmpeg will be transmitted via pipe transport, this will happen automatically if you use #video=mjpeg
  • MJPEG format now support hardware transcoding #video=mjpeg#hardware
  • MJPEG format can be used as direct output from USB cameras that support it

FFmpeg Device (USB)

New webpage for FFmpeg devices that helps you to add USB cameras.
If cameras support MJPEG or H264 format - you can add them without transcoding.
You can also choose the camera resolution that suits you best.

image

FFmpeg Hardware

New webpage for FFmpeg Hardware can show if hardware transcoding can be used and for which formats:

Intel Nuc i3 gen 10 (Linux Docker):

image

ASUS ROG Notebook (Windows):

image_2023-05-05_08-32-03

Raspberry Pi 3 (HassIO):

image

Apple MacBook M1 (macOS):

image

JPEG snapshots

All streams now support JPEG snapshots. For MJPEG streams frame is taken directly.
For H264/H265 cameras automatic transcoding with FFmpeg is used.

Version 2024.1.2 causes integration issues with SONOFF devices

After installing the 2024.1.2 core update, SONOFF integration issues occurred.
HA did not recognize entities status changes, toggle service calls only went one way -> to ON and not OFF, probably because to the status recognition issues.
After downgrading to core version 2023.12.1 problem solved.

Howto SSH to HassOS

ATTENTION! By using these instructions you agree not to ask for support from Hass community for your current Hass installation.

Local way

USB drive

Remote way

  1. Install SSH addon
  2. Add your key to addon config
    username: root
    authorized_keys:
    - ssh-rsa AASDJKJKJFWJFAFLCNALCMLAK234234.....
  3. Disable addon Protection mode option
  4. Open addon Web UI
    ~ cp /etc/ssh/authorized_keys /share
    ~ docker run -it --rm -v /root:/mnt/root -v /mnt/data/supervisor/share:/mnt/share bash cp /mnt/share/authorized_keys /mnt/root/.ssh
    ~ rm /share/authorized_keys
    ~ ha host reboot

Thats all. Now you have:

  • SSH on port 22 - addon
  • SSH on port 22222 - hassio host

Support Xiaomi Multimode Gateway on firmware 1.5.5

On previous firmware versions of the gateway, only the MiHome token was required to open the telnet. On firmware 1.5.5 this method was blocked.

Software method with key

Open telnet with gateway key. Only useful if you received the key on old gateway firmwares. There is no known way to get the key without a working telnet.

Attention! Gateway key is not a token.

Integration Xiaomi Gateway 3 starting from version 3.3.0 supports adding a gateway on firmware 1.5.5 using a token and a key.

The integration also automatically saves the key to the following places:

  • /config/.storage/core.config_entries
  • /config/.storage/xiaomi_gateway3/keys.json

It is recommended to securely save your gateway key, even if you have a gateway of a different model. You might need it in the future updates.

Software method with button

Open telnet with gateway button clicks. Only useful if your gateway was previously connected to the integration Xiaomi Gateway 3. Because otherwise there will be a password on the telnet. There is no known way to get this password.

5 clicks, pause, 2 clicks, pause, 2 clicks, pause, 2 clicks, pause, 2 clicks, pause, 2 clicks, pause, 2 clicks, pause.
https://www.youtube.com/shorts/qJ21wWNE1Gg

Warning! Incorrect clicks can reset the gateway. 10 clicks - reset gateway.

Hardware method with UART

https://github.com/AlexxIT/XiaomiGateway3/wiki

Chinese WLAN camera

Hi Alex, really appreciate your work here. I'm very interested in techy stuff but am away from coding like from here to the moon.

I bought some cooau cams at Amazon just to watch my dog outside the house.
I cannot get a stream on vlc or ispy. I paired it with an app called cloudedge and there I have a stream after connecting via qr code.

1 Should I reset the device before trying to connect with your software?
2 is it possible to see the stream on the app and on my PC (windows 10)?
3 is there any chance this won't work with this particular camera?

Support H265 for WebRTC in Safari with go2rtc

go2rtc is one of the first projects in the World, that support HEVC/H.265 for WebRTC in web browser.

Maybe you can see articles about WebRTC H265 earlier. But I haven't seen any examples where the video was displayed in a popular browser. Some projects can support WebRTC H265 if they are used on the receiving and transmitting sides. But what if there is a real browser on one side?

I tried streaming the RTSP from the Dahua camera to Safari with Janus without success. This works for some H264 cameras, but not all of them. This can work for streaming H265 between two Apple devices. But this does not work for H265 cameras.

All because Apple doesn't respect world standards. You can forgot RTP Payload Format for High Efficiency Video Coding (HEVC) (RFC 7798) then work with Apple devices. They invented their own payload:

  1. You need a correct H265 stream: VPS, SPS, PPS, I-frame, P-frame(s).
  2. You need it with Annex-B headers 00 00 00 01 before each NAL unit.
  3. You need split your stream on RTP payloads with one byte header:
    • 03 for payload with VPS, SPS, PPS, I-frame start
    • 01 for all next packets from this I-frame
    • 02 for payload with P-frame
    • 00 for all next packets from this P-frame
  4. Don't forget set marker flag only for last packet of each Access Units

That's all. Now anyone can try to watch WebRTC H265 in Safari even if don't have H265 cameras. This is because go2rtc has optional transcode feature for almost any stream source:

streams:
  sonoff_camera: ffmpeg:rtsp://rtsp:[email protected]:554/av_stream/ch0#video=h265#audio=copy

If you have H265 camera, you can stream it without transcoding, even from Xiaomi Gateway 3. Because go2rtc is a small application that you can install almost anywhere.

Unfortunately Safari is the only browser at the moment that supports H265 for WebRTC.

Codecs madness

Device WebRTC MSE MP4
latency best medium bad
Desktop Chrome H264 H264, H265* H264, H265*
Desktop Safari H264, H265* H264 no
Desktop Edge H264 H264, H265* H264, H265*
Desktop Firefox H264 H264 H264
Desktop Opera no H264 H264
iPhone Safari H264, H265* no no
iPad Safari H264, H265* H264 no
Android Chrome H264 H264 H264
masOS Hass App no no no

The key for the Xiaomi multimode 2 gateway is all same?

Just to ask I bought a Xiaomi multimode 2 gateway and accidentally update the firmware to 1.0.7.
If I buy another Xiaomi multimode 2 gateway and the firmware is 1.0.6. and I get the key from the second Xiaomi multimode 2 gateway.

Can the key from the second Xiaomi multimode 2 gateway apply on the first multimode 2 gateway which is 1.0.7?

thanks in advance for your reply

Reload WebRTC automatically in HA

Hi,
Is it possible to edit one of the configuration files of the WebRTC integration in order to reload it every 30 mins, for example? I'm using HAOS, there is a service called homeassistant.reload_config_entry but I cannot find any entry ID related to WebRTC.

Thanks!

go2rtc v1.9.4 adds streaming network graph in DOT format

New feature in latest release:

network

go2rtc.yaml

streams:
  rtsp-dahua1: rtsp://admin:***@192.168.10.90/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif
  rtsp-tplink1: rtsp://admin:***@192.168.10.91/stream1
  rtsp-sonoff1: rtsp://admin:***@192.168.10.93/av_stream/ch0
  http-reolink1: http://192.168.10.92/flv?port=1935&app=bcs&stream=channel0_main.bcs&user=admin&password=***
  tapo1: tapo://***@192.168.10.91:8800
  homekit-g3:
    - homekit://192.168.10.30:12345?client_id=***&client_private=***&device_id=***&device_public=***
    - ffmpeg:homekit-g3#audio=aac#audio=opus

ZBBridge not working

Hi, with updates after Sonoff Lan version 3.5.4 the Sonoff ZBBridge zigbee hub is no longer recognized. will it be restored in the next updates?

Wrong open telnet command

Hi everyone, trying to add Xiaomi Gateway 3

  • Model: ZNDMWG02LM - lumi.gateway.mgl03
    but I can't seem to enable telnet on the device (the token is correct)
    FW: 1.4.6_0040

Tried;
{"id":0,"method":"enable_telnet_service", "params":[]}
{"method":"set_ip_info","params":{"ssid":"""","pswd":"123123 ; passwd -d admin ; echo enable > /sys/class/tty/tty/enable; telnetd"}}

error="x509: certificate is valid for 127.0.0.1, fe80::1, not 172.16.82.2"

Is there the ability to ignore ssl certificate valid status?
I was tinkering around with HASS today and part of the tinkering brought this into the mix. 172.16.72.2 is the internal IP for my Unifi NVR

02:07:56.693 INF go2rtc version 0.1-rc.5 linux/amd64
02:07:56.693 INF [api] listen addr=:1984
02:07:56.695 INF [rtsp] listen addr=:8554
02:07:56.697 INF [hass] load stream url="hass:Scrypted D094"
02:07:56.697 INF [srtp] listen addr=:8443
02:17:13.578 ERR github.com/AlexxIT/go2rtc/cmd/streams/producer.go:51 > error="x509: certificate is valid for 127.0.0.1, fe80::1, not 172.16.82.2"
02:17:13.587 ERR github.com/AlexxIT/go2rtc/cmd/streams/producer.go:51 > error="x509: certificate is valid for 127.0.0.1, fe80::1, not 172.16.82.2"
02:17:13.587 WRN github.com/AlexxIT/go2rtc/cmd/webrtc/webrtc.go:197 > stream.AddConsumer error="sources unavailable: 1"
02:17:13.588 ERR [api.hass] exchange SDP error="sources unavailable: 1"

BIG rework of integration Xiaomi Gateway 3

IMPORTANT

  • The version is under development and will be called v4.0.0
  • This post has been updated over time
  • It is highly recommended to make a backup before upgrading!

Why? With the yet another Home Assistant update, the mechanism of creating entities was broken. They only worked when the Home Assistant was started. And became unavailable with any restart of the integration.

Creating entities is a very complicated part of integration. Some may be created on the first connection to the gateway. Some may appear when new devices are connected. If there are no converters for the device - entities can be created when the first data from the device appears.

But the most difficult part is that multiple integrations (gateways) may try to create the same entity. This works for BLE, Mesh, and sometimes even Zigbee devices. This behavior is not supported by the Home Assistant core. And needs to be coded very carefully.

So I decided to rework the entire component once again.

Breaking changes

A lot of things have changed in the integration and something may not work and something has to be manually updated.

Converters

All converters moved to /xiaomi_gateway3/core/devices.py.
All entities descriptions moved to /xiaomi_gateway3/hass/entity_description.py.

Basic converter class simplified

# before
@dataclass
class Converter:
    attr: str  # hass attribute
    domain: Optional[str] = None  # hass domain

    mi: Optional[str] = None
    parent: Optional[str] = None

    enabled: Optional[bool] = True  # support: True, False, None (lazy setup)
    poll: bool = False  # hass should_poll

    # don't init with dataclass because no type:
    childs = None  # set or dict? of children attributes
    zigbee = None  # str or set? with zigbee cluster

# after
@dataclass
class BaseConv:
    attr: str
    domain: str = None
    mi: str | int = None
    entity: dict = None

Deprecated enabled=False

  • Moved to entity.enabled=False param
# before
BoolConv("led", "switch", mi="6.p.6", enabled=False),
# after
BoolConv("led", "switch", mi="6.p.6", entity={"enabled": False}),

Deprecated enabled=None

  • Moved to entity.lazy=True param
# before
Converter("battery", "sensor", enabled=None),  # no in new firmwares
# after
Converter("battery", "sensor", entity={"lazy": True}),

Deprecated parent="..."

  • Now the entities know what attributes they need to subscribe to
# before
{
    "lumi.light.aqcn02": ["Aqara", "Bulb CN", "ZNLDP12LM"],
    "spec": [
        BoolConv("light", "light", mi="4.1.85"),
        ZXiaomiBrightnessConv("brightness", mi="14.1.85", parent="light"),
        ZXiaomiColorTempConv("color_temp", mi="14.2.85", parent="light"),
        MapConv("power_on_state", "select", mi="8.0.2030", map=BULB_MEMORY, enabled=False),
    ],
}
# after
{
    "lumi.light.aqcn02": ["Aqara", "Bulb CN", "ZNLDP12LM"],
    "spec": [
        BoolConv("light", "light", mi="4.1.85"),
        ZLumiBrightness("brightness", mi="14.1.85"),
        ZLumiColorTemp("color_temp", mi="14.2.85"),
        ZTransitionConv("transition"),
        MapConv("power_on_state", "select", mi="8.0.2030", map={0: "on", 1: "previous"}),  # config
    ],
}

Setup entity description inside converter

MathConv("occupancy_duration", "sensor", mi="2.p.3", entity={"category": "diagnostic", "enabled": False, "units": UNIT_MINUTES}),

Multiple models

  • Now is OK to add multiple models to device
  • For all BLE and Mesh devices it is recommended to add MiHome model (hhcc.plantmonitor.v1)
# before
"lumi.gateway.mgl03": ["Xiaomi", "Multimode Gateway", "ZNDMWG03LM"]
"lumi.gateway.mgl001": ["Xiaomi", "Multimode Gateway 2 EU", "ZNDMWG04LM"],
152: ["Xiaomi", "Flower Care", "HHCCJCY01"],
1371: ["Xiaomi", "TH Sensor 2", "LYWSD03MMC"],

# after
"lumi.gateway.mgl03": ["Xiaomi", "Multimode Gateway", "ZNDMWG03LM", "ZNDMWG02LM", "YTC4044GL"],
"lumi.gateway.mgl001": ["Xiaomi", "Multimode Gateway 2 EU", "ZNDMWG04LM", "BHR6765GL"],
152: ["Xiaomi", "Flower Care", "HHCCJCY01", "hhcc.plantmonitor.v1"],
1371: ["Xiaomi", "TH Sensor 2", "LYWSD03MMC", "miaomiaoce.sensor_ht.t2"],

BLE old converters

  • MiBeacon converter deprecated (MiBeacon)
  • Prebuild converters deprecated (BLETemperature...)
  • mi param now support eid from MiBeacon messages
  • BLEByteConv, BLEMathConv, BLEFloatConv supports unpack MiBeacon data
# before
{
    152: ["Xiaomi", "Flower Care", "HHCCJCY01"],
    "spec": [
        MiBeacon, BLETemperature, BLEMoisture, BLEConductivity, BLEIlluminance,
        Converter("battery", "sensor", enabled=None),  # no in new firmwares
    ],
}
# after
{
    152: ["Xiaomi", "Flower Care", "HHCCJCY01", "hhcc.plantmonitor.v1"],  # 4100,4103,4104,4105
    "spec": [
        BLEMathConv("temperature", "sensor", mi=4100, multiply=0.1, round=1, signed=True),  # int16
        BLEMathConv("illuminance", "sensor", mi=4103),  # uint24
        BLEByteConv("moisture", "sensor", mi=4104),  # uint8
        BLEMathConv("conductivity", "sensor", mi=4105),  # uint16
        BLEByteConv("battery", "sensor", mi=4106, entity=ENTITY_LAZY),  # uint8
    ],
}

BLE new converters

# before
{
    4611: ["Xiaomi", "TH Sensor", "XMWSDJ04MMC"],
    "spec": [
        MiBeacon, BLETemperature, BLEHumidity,
        # https://github.com/AlexxIT/XiaomiGateway3/issues/929
        MathConv("temperature", mi="3.p.1001", round=1),
        MathConv("humidity", mi="3.p.1008", round=1),
        Converter("battery", mi="2.p.1003"),
        Converter("battery", "sensor", enabled=None),  # no in new firmwares
    ],
}
# after
{
    4611: ["Xiaomi", "TH Sensor", "XMWSDJ04MMC", "miaomiaoce.sensor_ht.t6"],
    "spec": [
        # mibeacon2 spec
        BLEFloatConv("temperature", "sensor", mi=19457, round=1),  # float
        BLEFloatConv("humidity", "sensor", mi=19464, round=1),  # float
        BLEByteConv("battery", "sensor", mi=18435),  # uint8
        # miot https://github.com/AlexxIT/XiaomiGateway3/issues/929
        MathConv("temperature", mi="3.p.1001", round=1),
        MathConv("humidity", mi="3.p.1008", round=1),
        BaseConv("battery", mi="2.p.1003"),
    ],
}

MiOT spec buttons

  • ButtonMIConv("button") deprecated, ConstConv("action") should be used
# before
{
    11332: ["PTX", "Mesh Double Wall Switch", "090615.switch.aksk2"],
    "spec": [
        Converter("action", "sensor", enabled=False),
        ButtonMIConv("button_1", mi="8.e.1", value=1),
        ButtonMIConv("button_1", mi="8.e.2", value=2),
    ],
}
# after
{
    11332: ["PTX", "Mesh Double Wall Switch", "090615.switch.aksk2"],
    "spec": [
        BaseConv("action", "sensor", entity=ENTITY_DISABLED),
        ConstConv("action", mi="8.e.1", value=BUTTON_SINGLE),
        ConstConv("action", mi="8.e.2", value=BUTTON_DOUBLE),
    ],
}

MiOT events

  • mi="3.e.1012" changed to "3.e.1012.p.1" if event has params
# before
{
    # https://github.com/AlexxIT/XiaomiGateway3/issues/826
    7184: ["Linptech", "Wireless Button", "K11"],
    "spec": [
        MiBeacon, BLEAction, Button, BLEBattery,
        Converter("battery", mi="2.p.1003"),
        BLEEvent("action", mi="3.e.1012", map={1: SINGLE, 8: HOLD, 15: DOUBLE}),
    ],
}
# after
{
    # https://github.com/AlexxIT/XiaomiGateway3/issues/826
    7184: ["Linptech", "Wireless Button", "K11", "linp.remote.k9b01"],
    "spec": [
        # mibeacon2 spec
        BLEMapConv("action", "sensor", mi=19980, map={"01": BUTTON_SINGLE, "08": BUTTON_HOLD, "0F": BUTTON_DOUBLE}),
        BLEByteConv("battery", "sensor", mi=18435),  # uint8
        # miot spec
        MapConv("action", mi="3.e.1012.p.1", map={1: BUTTON_SINGLE, 8: BUTTON_HOLD, 15: BUTTON_DOUBLE}),
        BaseConv("battery", mi="2.p.1003"),
    ],
}

Zigbee converters

  • Now linked to ZHA contants to increase readability
# before
class ZOnOffConv(ZBoolConv):
    zigbee = "on_off"
    zattr = "on_off"

    def encode(self, device: "XDevice", payload: dict, value: bool):
        cmd = zcl_on_off(device.nwk, self.ep, value)
        payload.setdefault("commands", []).extend(cmd)

# after
from zigpy.zcl.clusters.general import OnOff

class ZOnOffConv(ZBoolConv):
    cluster_id = OnOff.cluster_id
    attr_id = OnOff.AttributeDefs.on_off.id

    def encode(self, device: "XDevice", payload: dict, value: bool):
        cmd = zcl_on_off(device.nwk, self.ep, value)
        payload.setdefault("commands", []).extend(cmd)

Custom entities for models

# before
def new_entity(gateway: XGateway, device: XDevice, conv: Converter) -> XEntity:
    if conv.mi == "4.21.85":
        return AqaraE1(gateway, device, conv)
    if device.model == 14050:
        return ScdvbHAVC(gateway, device, conv)
    else:
        return XiaomiClimate(gateway, device, conv)

# after
XEntity.NEW["climate.model.lumi.airrtc.tcpecn02"] = XAqaraS2  
XEntity.NEW["climate.model.lumi.airrtc.agl001"] = XAqaraE1  
XEntity.NEW["climate.model.14050"] = XScdvbHAVC

Customize deprecated

  • Moved to xiaomi_gateway3.devices
# before
homeassistant:
  customize:
    binary_sensor.0x00158d00ccddeeff_motion:
      occupancy_timeout: 180

# after
xiaomi_gateway3:
  devices:
    "0x00158d00ccddeeff":
      occupancy_timeout: 180

Stats sensors

Now can be either sensor or binary_sensor. The sensor data has also changed:

  • Many useful info about uid, did, mac, brand, model, market and cloud names
  • List of connected gateways
  • Time from last message and info about last gateway
  • Total payload from all messages
extra:
  cloud_fw: 2.1.1_0037
  cloud_name: Home Lamp 1
  did: '1234567890'
  mac: 50:ec:50:aa:bb:cc
  market_brand: Xiaomi
  market_model: MJDP09YL, yeelink.light.mbulb3
  market_name: Mesh Bulb
  rssi_54ef44ccddff: -77
  rssi_6490c1ccddff: -52
  type: mesh
gateways: 54ef44ccddff, 6490c1ccddff
last_decode: 6m8s
last_decode_gw:
  fw_ver: 1.5.4_0090
  host: 192.168.1.123
  mac: 64:90:c1:cc:dd:ff
  model: lumi.gateway.mgl03
last_encode: 6m9s
last_report:
  light: false
model: 1771
payload:
  brightness: 255.0
  color_temp: 190
  flex_switch: true
  light: false
ttl: 20m
uid: 50ec50aabbcc

Stats table

type: custom:flex-table-card
clickable: true
columns:
  - data: name
    name: Name
  - data: device.uid
    name: UID
  - data: msg_received
    name: Recv
    modify: x+''
  - data: msg_missed
    name: Miss
    modify: x+''
  - data: device.extra.seq
    name: SEQ
    modify: x+''
  - data: device.extra.rssi
    name: RSSI
    modify: x+''
  - data: device.last_decode_gw.host
    name: Gateway
    modify: x+''
  - data: state
    name: Available
  - data: last_updated
    name: Last changed
entities:
  include:
    - binary_sensor.*_ble
    - binary_sensor.*_mesh
    - binary_sensor.*_zigbee

Attributes template

# before
xiaomi_gateway3:
  attributes_template: |  
    {% if attr in ('zigbee', 'ble', 'mesh') %}  
    {{{  
      "name": device.info.name,  
      "device_fw_ver": device.fw_ver,  
      "device_model": device.model,  
      "device_market_model": device.info.model,  
      "device_manufacturer": device.info.manufacturer,  
      "integration": "gw3",  
      "gate": gateway.info.name,  
      "gateway_model": gateway.info.model,  
      "gateway_fw_ver": gateway.fw_ver  
    }}}  
    {% elif attr == 'gateway' %}  
    {{{  
      "integration": "gw3",  
      "gate": gateway.info.name,  
      "gateway_model": gateway.info.model,  
      "gateway_fw_ver": gateway.fw_ver  
    }}}  
    {% elif attr == 'battery' %}  
    {{{  
      "integration": "gw3",  
      "name": device.info.name,  
      "gate": gateway.info.name,  
      "battery": "true"  
    }}}  
    {% endif %}

# after
xiaomi_gateway3:
  attributes_template: |
    {% if attr in ('zigbee', 'ble', 'mesh') %}
    {{{
      "integration": "gw3",
      "name": device.human_name,
      "device_fw_ver": device.firmware,
      "device_model": device.model,
      "device_market_model": device.human_model,
      "device_manufacturer": device.extra.market_brand,
      "gate": gateway.human_name,
      "gateway_model": gateway.model,
      "gateway_fw_ver": gateway.firmware
    }}}
    {% elif attr == 'gateway' %}
    {{{
      "integration": "gw3",
      "gate": gateway.human_name,
      "gateway_model": gateway.human_model,
      "gateway_fw_ver": gateway.firmware
    }}}
    {% elif attr == 'battery' %}
    {{{
      "integration": "gw3",
      "name": device.human_name,
      "gate": gateway.human_name,
      "battery": "true"
    }}}
    {% endif %}

Logging

Log format also have been reworked. Now you can control basic and mqtt logs from:

  • Integration config (each type of data for each gateway)
  • Global integration debug logs from Home Assistant Web UI
  • configuration.yaml
logger:
  default: warning
  logs:
    custom_components.xiaomi_gateway3: warning
    custom_components.xiaomi_gateway3.gate: info
    custom_components.xiaomi_gateway3.mqtt: info
    custom_components.xiaomi_gateway3.gate.192.168.1.123: debug
    custom_components.xiaomi_gateway3.mqtt.192.168.1.234: debug

Command select

Now EVERY device has command select. Options list depends to device type:

  • Device info - shows full device info in the Home Assistant notification. Same info you get in the stats sensors and in device diagnostics
  • Device update - request state update from device. BLE devices and many battery Zigbee devices can't be requested
  • Device delete - only Zigbee device option. Sends leave signal to Zigbee device

Cloud Integration

  • Now supports multiple accounts
  • Now supports reloading the integration to update data
  • Shows more information about devices
  • Fixed name support for new Zigbee devices

Zigbee force pairing

In the default "zigbee pairing" mode you can pair supported MiHome zigbee devices and 3rd party zigbee devices. But you can't pair unsupported MiHome zigbee devices.
In this mode you can pair any zigbee device, but it won't be displayed in the MiHome even if supported.

RSSI

Now supported for BLE and Mesh. Data is logged separately for each gateway.

Mesh groups

Now Mesh groups is another device type. Groups of different models (light, cover) are also supported.

Matter

Support Matter child devices for Xiaomi Miltimode Gateway 2 (EU) on fw 1.0.7_0019.

Device triggers

Was changed from multiple types and multiple actions. To one type - action and multiple states.
If you used device triggers - them should be updated manually.

Delete device

Now deleting Home Assistant device won't delete it from Gateway. For deleting Zigbee device you can use "command select". For deleting other devices you should use MiHome.

Gateway alarm

Now has trigger for enabling and disabling.

Gateway disabling

Now gateways has disable and enable options via "command select". Them just for test, so you can check if your BLE/Mesh devices still can be controlled when some of your gateways down.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.