Connect GEM to Home Assistant

Ask questions about the GEM here.
rogerfar
Posts: 11
Joined: Tue Jan 18, 2022 10:45 pm

Connect GEM to Home Assistant

Post by rogerfar » Tue Jan 18, 2022 10:50 pm

Hi all,

I just setup my first GEM and I'm trying to connect it to HA.

I have the Wifi/Ethernet module. The Home Assistant Greeneye configuration runs at 192.168.10.5 on port 8000.

On the GEM setup page I changed the Network to 192.168.10.5 and port 8000, that's the only setting I changed.

I can connect to it with the GEM Network Utility and I see live data, but Home Assistant doesn't report anything, all channels and voltage sensors remain as no data

I triple checked the serial number, oddly the number reported in the interface is different than written on the box itself, but I'm assuming the UI one is the correct one.

Is there a step I'm missing?
ben
Site Admin
Posts: 4262
Joined: Fri Jun 04, 2010 9:39 am

Re: Connect GEM to Home Assistant

Post by ben » Thu Jan 20, 2022 10:20 am

rogerfar wrote:
Tue Jan 18, 2022 10:50 pm
Hi all,

I just setup my first GEM and I'm trying to connect it to HA.

I have the Wifi/Ethernet module. The Home Assistant Greeneye configuration runs at 192.168.10.5 on port 8000.

On the GEM setup page I changed the Network to 192.168.10.5 and port 8000, that's the only setting I changed.

I can connect to it with the GEM Network Utility and I see live data, but Home Assistant doesn't report anything, all channels and voltage sensors remain as no data

I triple checked the serial number, oddly the number reported in the interface is different than written on the box itself, but I'm assuming the UI one is the correct one.

Is there a step I'm missing?
What packet format do you have set on the GEM?

Can you post your HA configuration file?
Ben
Brultech Research Inc.
E: ben(at)brultech.com
rogerfar
Posts: 11
Joined: Tue Jan 18, 2022 10:45 pm

Re: Connect GEM to Home Assistant

Post by rogerfar » Thu Jan 20, 2022 5:05 pm

I tried both Bin32 NET and Bin48 NET.

This is my configuration.yaml:

Code: Select all

greeneye_monitor:
  port: 8000
  monitors:
    - serial_number: "01120990"
      channels:
        - number: 1
          name: ge_panel_plug_1
        - number: 2
          name: ge_panel_plug_2
      voltage:
        - number: 1
          name: ge_voltage
All 3 sensors show up in HA, but no data gets entered for it.
ben
Site Admin
Posts: 4262
Joined: Fri Jun 04, 2010 9:39 am

Re: Connect GEM to Home Assistant

Post by ben » Fri Jan 21, 2022 1:03 pm

rogerfar wrote:
Thu Jan 20, 2022 5:05 pm
I tried both Bin32 NET and Bin48 NET.

This is my configuration.yaml:

Code: Select all

greeneye_monitor:
  port: 8000
  monitors:
    - serial_number: "01120990"
      channels:
        - number: 1
          name: ge_panel_plug_1
        - number: 2
          name: ge_panel_plug_2
      voltage:
        - number: 1
          name: ge_voltage
All 3 sensors show up in HA, but no data gets entered for it.
Are you running HA on Windows or Linux? You can try this suggestion I had for another user:

Code: Select all

python btmon.py --print --debug --device-type=gem --ip --ip-mode=server --ip-port 8000
https://github.com/BenK22/mtools/tree/influxdb/bin (btmon3.py for Python 3, btmon.py for Python 2.7)

If BTMon.py can read the input then we know it's something on the HA end.
Ben
Brultech Research Inc.
E: ben(at)brultech.com
rogerfar
Posts: 11
Joined: Tue Jan 18, 2022 10:45 pm

Re: Connect GEM to Home Assistant

Post by rogerfar » Fri Jan 21, 2022 2:00 pm

I ran btmon with python3, it does get packets, but they don't get decoded:

Code: Select all

2022/01/21 11:56:13 btmon: 4.0.0
2022/01/21 11:56:13 python: 3.10.1 (tags/v3.10.1:2cd268a, Dec  6 2021, 19:10:37) [MSC v.1929 64 bit (AMD64)]
2022/01/21 11:56:13 platform: win32
2022/01/21 11:56:13 device type: gem
2022/01/21 11:56:13 device list: ['']
2022/01/21 11:56:13 packet format: gem48ptbin
2022/01/21 11:56:13 schema: counters
2022/01/21 11:56:13 buffer size: 120
2022/01/21 11:56:13 SOCKET: bind host:
2022/01/21 11:56:13 SOCKET: bind port: 8000
2022/01/21 11:56:13 packet format is GEM48PTBinaryPacket
2022/01/21 11:56:13 using collector SocketServerCollector
2022/01/21 11:56:13 using 1 processors:
2022/01/21 11:56:13   PrintProcessor
2022/01/21 11:56:13 setup SocketServerCollector
2022/01/21 11:56:13 SOCKET: binding to :8000
2022/01/21 11:56:13 setup PrintProcessor
2022/01/21 11:56:13 SOCKET: waiting for connection
2022/01/21 11:56:14 waiting for data from device
2022/01/21 11:56:14 reading 1 of 1 packets
2022/01/21 11:56:14 SOCKET: read 1 of 1 bytes from socket: b'80'
2022/01/21 11:56:14 read failed: expected START_HEADER0 0xfe, got 0x80
2022/01/21 11:56:14 reading 1 of 1 packets
2022/01/21 11:56:14 SOCKET: read 1 of 1 bytes from socket: b'80'
2022/01/21 11:56:14 read failed: expected START_HEADER0 0xfe, got 0x80
2022/01/21 11:56:14 reading 1 of 1 packets
2022/01/21 11:56:14 SOCKET: read 1 of 1 bytes from socket: b'80'
2022/01/21 11:56:14 read failed: expected START_HEADER0 0xfe, got 0x80
2022/01/21 11:56:14 reading 1 of 1 packets
2022/01/21 11:56:14 SOCKET: read 1 of 1 bytes from socket: b'80'
2022/01/21 11:56:14 read failed: expected START_HEADER0 0xfe, got 0x80
2022/01/21 11:56:14 reading 1 of 1 packets
.....
I tried sending BIN48-NET, BIN48-NET-Time, Bin32-NET, same result.
ben
Site Admin
Posts: 4262
Joined: Fri Jun 04, 2010 9:39 am

Re: Connect GEM to Home Assistant

Post by ben » Fri Jan 21, 2022 4:45 pm

rogerfar wrote:
Fri Jan 21, 2022 2:00 pm
I ran btmon with python3, it does get packets, but they don't get decoded:

Code: Select all

2022/01/21 11:56:13 btmon: 4.0.0
2022/01/21 11:56:13 python: 3.10.1 (tags/v3.10.1:2cd268a, Dec  6 2021, 19:10:37) [MSC v.1929 64 bit (AMD64)]
2022/01/21 11:56:13 platform: win32
2022/01/21 11:56:13 device type: gem
2022/01/21 11:56:13 device list: ['']
2022/01/21 11:56:13 packet format: gem48ptbin
2022/01/21 11:56:13 schema: counters
2022/01/21 11:56:13 buffer size: 120
2022/01/21 11:56:13 SOCKET: bind host:
2022/01/21 11:56:13 SOCKET: bind port: 8000
2022/01/21 11:56:13 packet format is GEM48PTBinaryPacket
2022/01/21 11:56:13 using collector SocketServerCollector
2022/01/21 11:56:13 using 1 processors:
2022/01/21 11:56:13   PrintProcessor
2022/01/21 11:56:13 setup SocketServerCollector
2022/01/21 11:56:13 SOCKET: binding to :8000
2022/01/21 11:56:13 setup PrintProcessor
2022/01/21 11:56:13 SOCKET: waiting for connection
2022/01/21 11:56:14 waiting for data from device
2022/01/21 11:56:14 reading 1 of 1 packets
2022/01/21 11:56:14 SOCKET: read 1 of 1 bytes from socket: b'80'
2022/01/21 11:56:14 read failed: expected START_HEADER0 0xfe, got 0x80
2022/01/21 11:56:14 reading 1 of 1 packets
2022/01/21 11:56:14 SOCKET: read 1 of 1 bytes from socket: b'80'
2022/01/21 11:56:14 read failed: expected START_HEADER0 0xfe, got 0x80
2022/01/21 11:56:14 reading 1 of 1 packets
2022/01/21 11:56:14 SOCKET: read 1 of 1 bytes from socket: b'80'
2022/01/21 11:56:14 read failed: expected START_HEADER0 0xfe, got 0x80
2022/01/21 11:56:14 reading 1 of 1 packets
2022/01/21 11:56:14 SOCKET: read 1 of 1 bytes from socket: b'80'
2022/01/21 11:56:14 read failed: expected START_HEADER0 0xfe, got 0x80
2022/01/21 11:56:14 reading 1 of 1 packets
.....
I tried sending BIN48-NET, BIN48-NET-Time, Bin32-NET, same result.
I suspect you have Real-Time turned off under Packet Send. It'll send a keep alive every so often when that's turned off.
Ben
Brultech Research Inc.
E: ben(at)brultech.com
rogerfar
Posts: 11
Joined: Tue Jan 18, 2022 10:45 pm

Re: Connect GEM to Home Assistant

Post by rogerfar » Fri Jan 21, 2022 6:09 pm

You mean here?

Image

I do see packets coming in every 5 seconds, and when entering setup mode it stops.
rogerfar
Posts: 11
Joined: Tue Jan 18, 2022 10:45 pm

Re: Connect GEM to Home Assistant

Post by rogerfar » Sat Jan 22, 2022 1:13 pm

I'm a bit at a loss here, I have tried various tools now, and now I'm intercepting the raw packets that come from the GEM.

It's definitely sending every 5 seconds, that's obvious, but no matter what packet format I set it as, it always sends 256 x 0x80, nothing else.

This is a capture from Wireshark:
Image
rogerfar
Posts: 11
Joined: Tue Jan 18, 2022 10:45 pm

Re: Connect GEM to Home Assistant

Post by rogerfar » Sat Jan 22, 2022 1:26 pm

Managed to make it work, turns out that if you leave COM2 as "Disabled" it does NOT do what the manual states, it basically prevents all communication.

I set COM2 to BIN32 and COM1 to JSON and was able to receive the JSON. I now switched both to BIN32 and Home Assistant is now parsing the data.
ben
Site Admin
Posts: 4262
Joined: Fri Jun 04, 2010 9:39 am

Re: Connect GEM to Home Assistant

Post by ben » Mon Jan 24, 2022 10:28 am

rogerfar wrote:
Sat Jan 22, 2022 1:26 pm
Managed to make it work, turns out that if you leave COM2 as "Disabled" it does NOT do what the manual states, it basically prevents all communication.

I set COM2 to BIN32 and COM1 to JSON and was able to receive the JSON. I now switched both to BIN32 and Home Assistant is now parsing the data.
Is your COM1 or COM2 Flow Control on? They should both be set to "Off". That will cause it to hang as Flow Control is left floating.
Ben
Brultech Research Inc.
E: ben(at)brultech.com
Post Reply