All Projects → dariopb → ha-gosenseapp

dariopb / ha-gosenseapp

Licence: other
Application that uses the gosense library to discover and publish sensor information to HA via MQTT

Programming Languages

go
31211 projects - #10 most used programming language
Dockerfile
14818 projects

Projects that are alternatives of or similar to ha-gosenseapp

wyzesense2mqtt
Configurable WyzeSense to MQTT Gateway intended for use with Home Assistant or other platforms that use MQTT discovery mechanisms.
Stars: ✭ 55 (+44.74%)
Mutual labels:  homeassistant, wyzesense
home assistant omnik solar
Home Assistant Omnik Solar sensor component
Stars: ✭ 15 (-60.53%)
Mutual labels:  homeassistant
Addon Vscode
Visual Studio Code - Home Assistant Community Add-ons
Stars: ✭ 201 (+428.95%)
Mutual labels:  homeassistant
thermal
Thermal Vision Sensor and Camera for Home Assistant
Stars: ✭ 43 (+13.16%)
Mutual labels:  homeassistant
Pyscript
Pyscript adds rich Python scripting to HASS
Stars: ✭ 219 (+476.32%)
Mutual labels:  homeassistant
DahuaVTO
Control Dahua VTO/VTH devices from Home Assistant
Stars: ✭ 98 (+157.89%)
Mutual labels:  homeassistant
Ha Wyzeapi
Home Assistant Integration for Wyze Bulbs, Switches, Sensors and Lock
Stars: ✭ 187 (+392.11%)
Mutual labels:  homeassistant
ESPHome-Devices
A collection of ESPHome custom components, configuration files, and custom code for my various ESP8266/ESP32 devices that integrate with Home Assistant.
Stars: ✭ 83 (+118.42%)
Mutual labels:  homeassistant
Plate-Minder
Monitor a video source for license plates and record them. Zero cloud dependencies.
Stars: ✭ 106 (+178.95%)
Mutual labels:  homeassistant
ytube music player
YouTube music player for homeassistant
Stars: ✭ 226 (+494.74%)
Mutual labels:  homeassistant
Wukong Robot
🤖 wukong-robot 是一个简单、灵活、优雅的中文语音对话机器人/智能音箱项目,还可能是首个支持脑机交互的开源智能音箱项目。
Stars: ✭ 3,110 (+8084.21%)
Mutual labels:  homeassistant
Ems Esp
ESP8266 firmware to read and control EMS and Heatronic compatible equipment such as boilers, thermostats, solar modules, and heat pumps
Stars: ✭ 226 (+494.74%)
Mutual labels:  homeassistant
meta-homeassistant
OpenEmbedded Layer for Home Assistant - An open-source home automation platform running on Python 3
Stars: ✭ 30 (-21.05%)
Mutual labels:  homeassistant
Addon Node Red
Node-RED - Home Assistant Community Add-ons
Stars: ✭ 210 (+452.63%)
Mutual labels:  homeassistant
HomeAssistantRepository
🏡 Home Assistant on Gentoo Linux.
Stars: ✭ 26 (-31.58%)
Mutual labels:  homeassistant
Pai
Paradox Magellan, Spectra and EVO, with MQTT, Signal, Pushbullet, Pushover and others
Stars: ✭ 185 (+386.84%)
Mutual labels:  homeassistant
Esp Mqtt Rgb Led
MQTT RGB LEDs Using JSON for Home Assistant
Stars: ✭ 241 (+534.21%)
Mutual labels:  homeassistant
addon-vscode-remote
VSCode Remote - Home Assistant Community Add-ons
Stars: ✭ 35 (-7.89%)
Mutual labels:  homeassistant
ha-birthdays
Birthday integration for HomeAssistant
Stars: ✭ 14 (-63.16%)
Mutual labels:  homeassistant
youtube
A platform which give you info about the newest video on a channel
Stars: ✭ 40 (+5.26%)
Mutual labels:  homeassistant

ha-gosenseapp

This is an application that uses the gosense library (https://github.com/dariopb/gosense) to discover and publish sensor information to HA via the HA MQTT Discovery mechanism (https://www.home-assistant.io/docs/mqtt/discovery/) or simply by configuring the sensor info in the HA config file (https://www.home-assistant.io/docs/mqtt).

Configuration file

The configuration file for the application. At least an empty file needs to be provided and it will be populated with default values.

  • debuglevel The debug level for tracing info/debug [defaults to info if it is not set]

MQTT section

  • clientid The MQTT clientID to use [defaults to "ha-gosenseapp-xxxxx" if it is not set]
  • hostname The MQTT server to connect to. Empty disables MQTT [defaults to ""]
  • user The MQTT username to use [defaults to "" is not set]
  • password The MQTT username to use [defaults to "" is not set]
  • port The MQTT port to use [defaults to 1883]
  • discoveryTopic The MQTT-DISC for HA topic to use [defaults to "gosense_discovery" if it is not set]
  • sensorTopic The MQTT clientID to use [defaults to "gosense" if it is not set]

Sample configuration file

mqtt:
  clientid: goapp-001
  hostname: localhost
  user: ""
  password: ""
  port: 1883
  sensorTopic: gosense
  discoveryTopic: gosense_discovery

sensors:    <== sensor data is discovered and updated from the dongle
  0444001:
    metadata:
      name: 0444001
      mac: 0444001
      sensorType: 1
      present: true
    properties:
      battery: "94"
      signal: "40"
      state: "0"
      timeLastAlarm: "2019-07-06T00:20:09-07:00"

Run it!

Linux

# Create a config file as above and then mount that file to /app.yaml :
sudo docker run -it --rm --net host -v /home/xxxx/gosenseapp/app.yaml:/app.yaml --privileged dariob/gosenseapp:latest

Raspberry PI

# Create a config file as above and then mount that file:
sudo docker run -it --rm --net host -v /home/pi/gosenseapp/app.yaml:/app.yaml --privileged dariob/gosenseapp-pi:latest

MQTT Structure

This is the MQTT structure for the default MQTT settings:

├── gosense-discovery
│   └── binary_sensor
│       └── 0444001
│           └── config
│               └── JSON PAYLOAD
                      name: "PPPPP"
                      payload_on: "1"
                      payload_off: "0"
                      state_topic: "gosense/0444001"
                      value_template: "{{ value_json.properties.state }}"
                      json_attributes_topic: "gosense/0444001"
                      json_attributes_template: "{{ value_json.properties | tojson }}"
...
├── gosense
│   └── 0444002
│           └── JSON PAYLOAD
                    metadata:
                      name: 0444002
                      mac: 0444002
                      sensorType: 1
                      present: true
                    properties:
                      battery: '94'
                      signal: '40'
                      state: '1'
                      timeLastAlarm: '2019-07-06T00:20:09-07:00'

REST API

The application exposes a simple REST API on port 8080 to manipule the sense dongle and get "configuration ready" output to include in the HA conf file.

The endpoint should be: http://hostname:8080/xxx where xxx is as follows.

Routes exposed

  • /help Gets the list of exposed routes

  • ./hasensors Enumerates the sensors attached to the dongle in HA conf format

binarySensor:
- platform: mqttv
  name: 0444001
  unique_id: 0444001
  payload_on: "1"
  payload_off: "0"
  state_topic: gosense/0444001
  value_template: '{{ value_json.properties.state }}'
  json_attributes_topic: gosense/0444001
  json_attributes_template: '{{ value_json.properties | tojson }}'
- platform: mqtt
  name: 0444002
  unique_id: 0444002
  payload_on: "1"
  payload_off: "0"
  state_topic: gosense/0444002
  value_template: '{{ value_json.properties.state }}'
  json_attributes_topic: gosense/0444002
  json_attributes_template: '{{ value_json.properties | tojson }}'
  • /sensors Enumerates the sensors attached to the dongle
[{"metadata":{"name":"","mac":"","sensorType":0},"properties":{}},{"metadata":{"name":"0444001","mac":"0444001","sensorType":1},"properties":{"battery":"96","signal":"41","state":"0","timeLastAlarm":"2019-07-13T15:39:52-07:00"}},{"metadata":{"name":"0444002","mac":"0444002","sensorType":2},"properties":{"battery":"0","signal":"1","state":"5","timeLastAlarm":"2019-07-13T16:03:08-07:00"}}]
  • /sensors/:mac Get a sensor by its MAC address
  • /sensors/scan Sets the dongle in attach mode for 30 seconds. You can pair a new device in that time. The info about the new device is the response.
{"metadata":{"name":"0444002","mac":"0444002","sensorType":0},"properties":{}}
  • /sensors/:mac/remove Removes (unpairs) a sensor by MAC address

Docker

Create docker image:

cd cmd
env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -v -o gosenseapp
cd ..
sudo docker build -t dariob/gosenseapp:latest -f docker/Dockerfile .

Run on Raspberry PI

Please notice the --privileged flag needs to be passed in order to be able to access the host device.

root@rasp1:/home/pi/gosenseapp# docker run -it --rm --net host -v /home/pi/gosenseapp/app.yaml:/app.yaml --privileged dariob/gosenseapp-pi:latest
Unable to find image 'dariob/gosenseapp-pi:latest' locally
latest: Pulling from dariob/gosenseapp-pi
13ee9c2f1d69: Pull complete 
Digest: sha256:d2256eae3f6056dfd771c076b786b13de9a0c03375fd5499a64193f8f496747e
Status: Downloaded newer image for dariob/gosenseapp-pi:latest
ha-gosenseapp starting...
INFO[0000] Looking for sense dongle in /dev/hidraw*     
INFO[0000] Found sense dongle in [/dev/hidraw2]         
INFO[0000] NewWyzeSense: trying to open device: [/dev/hidraw2] 
INFO[0000] LOG: time=14 Jul 19 01:04 +0000, data=��     
INFO[0000] Starting echo REST API on port 8080          
INFO[0000] Starting HA MQTT publisher to [tcp://192.168.1.108:1883] 
INFO[0000]    MQTT trying to connect to: [tcp://192.168.1.108:1883] 
WARN[0000]    MQTT sucessfully connected to: [tcp://192.168.1.108:1883] 
INFO[0005] LOG: time=14 Jul 19 01:05 +0000, data=�77793E5A�� 
INFO[0005] ALARM: time=14 Jul 19 01:05 +0000, mac: 77793E5A, type: 1, battery: 97, signal: 91, state: 1, data=61000101000a5b 
INFO[0005] ALARM: 77793E5A, state: 1                    
INFO[0008] LOG: time=14 Jul 19 01:05 +0000, data=�77793E5A�
                                                            
INFO[0008] ALARM: time=14 Jul 19 01:05 +0000, mac: 77793E5A, type: 1, battery: 97, signal: 82, state: 0, data=61000100000b52 
INFO[0008] ALARM: 77793E5A, state: 0                    

Raspberry PI

cd cmd
env GOARCH=arm GOARM=5 GOOS=linux go build -o gosenseapp
#scp gosenseapp rasp:~/gosenseapp

cd ..
sudo docker build -t dariob/gosenseapp-pi:latest -f docker/Dockerfile .

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].