Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Huge code rewrite to be more adaptive + other fixes #16

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions .devcontainer.json

This file was deleted.

28 changes: 28 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "Example Home Assistant add-on repository",
"image": "ghcr.io/home-assistant/devcontainer:addons",
"appPort": ["7123:8123", "7357:4357"],
"postStartCommand": "bash devcontainer_bootstrap",
"runArgs": ["-e", "GIT_EDITOR=code --wait", "--privileged"],
"containerEnv": {
"WORKSPACE_DIRECTORY": "${containerWorkspaceFolder}"
},
"customizations": {
"vscode": {
"extensions": ["timonwong.shellcheck", "esbenp.prettier-vscode"],
"settings": {
"terminal.integrated.profiles.linux": {
"zsh": {
"path": "/usr/bin/zsh"
}
},
"terminal.integrated.defaultProfile.linux": "zsh",
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"files.trimTrailingWhitespace": true
}
}
},
"mounts": ["type=volume,target=/var/lib/docker"]
}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
# Misc
.env
man/
venv/
venv/
**/.DS_Store
156 changes: 69 additions & 87 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,74 @@ Smarthub with Home Assistant by using the local MQTT broker inside the hub.
While it is possible to configure Home Assistant the FIMP protocol
directly is a lot of work, and auto discovery is not possible.

This addon configure devices and their capabilities from Future Home in Home Assistant using MQTT Discovery.
This addon configure devices and their capabilities from Future Home in Home Assistant using [MQTT Discovery](https://www.home-assistant.io/integrations/mqtt/).

Read more about the [FIMP protocol](https://github.com/futurehomeno/fimp-api).


## Supported Futurehome devices

* Appliances (switches in HA)
* Wall plugs like Fibaro Wall plug is supported
* Lights (lights in HA)
* Dimmers - On/Off and brightness. Tested with Fibaro dimmer 2
* Switches - On/Off. Tested with Fibaro wall plug
* Sensors
* Battery
* Illuminance
* Presence
* Temperature
* Accumulated energy usage (kWh) (`meter_elec`) for devices supporting this
* Modus (home, away, sleep and vacation)
* Set in entity `sensor.fh_mode` (read only)


### Untested in new version (0.1 vs 0.2)

These things are probably no longer working

* Scene control. Exposed as sensor. Tested with Fibaro button, and Namron 4 channel (K8)
- Appliances (switches in HA)
- Wall plugs like Fibaro Wall plug is supported
- Boiler
- Connected with a relay device (e.g Futurehome Puck Relay)
- Lights (lights in HA)
- Dimmers - On/Off and brightness. Tested with Fibaro dimmer 2
- Switches - On/Off. Tested with Fibaro wall plug
- Locks
- Basic unlock/lock for doorlocks. Tested with IDLock 150 (Unlock commands are currently not supported on Zigbee)
- Thermostats
- Set mode
- Set target temp
- Read current measured temperature (Note that the temperature sensor that have the "Set as main temp sensor" checkbox checked in the Futurehome app will be used)
- Change fan speed if device supports it (e.g Sensibo)
- Sensors
- Battery
- Illuminance
- Presence
- Temperature
- Humidity
- Contact
- Meter_elec sensors (varies from device to device if they are supported)
- Accumulated energy usage (kWh)
- Power (W)
- Voltage (V)
- Current (A)
- p_import (W)
- e_import (kWh)
- p_import_react (var)
- p_export_react (var)
- Modus (home, away, sleep and vacation)
- Set in entity `select.fh_mode`
- Shortcuts

## Known issues / limitations

- Chargepoint (FH Charge, Easee, Zaptec etc.) is not currently supported
- Scene control (Fibaro button, Heatit Z-Push 4 etc.) is not currently supported
- Blinds are not currently supported
- Sirens are not currently supported
- Leak detectors are not currently supported
- Garage doors are not currently supported
- Music players (Sonos etc.) is not currently supported - use Sonos integration in Home Assistant
- Some devices might still use sensor_power (deprecated) and sensor_voltage (deprecated) instead of `meter_elec`. This needs to be fixed by Futurehome.
- Shortcuts triggered externally (e.g from Futurehome app) is not logged in logbook

# Configuration and installation

> [!IMPORTANT]
>
> You need to enable local API access over MQTT from the Futurehome app.
>
> `Settings -> household -> hub settings -> local API setup`

### 1. Home Assistant configuration

Home Assistant must use the MQTT broker provided by the Futurehome Smart hub.
Home Assistant must use the MQTT broker provided by the Futurehome Smarthub.
It's recommended to configure MQTT via GUI, and not via `.yaml`

Settings -> Device & services -> add integration -> search for `MQTT` -> select `MQTT` -> fill in hub IP and credentials. (NOTE that port should be 1884):

```
# MQTT
mqtt:
# Futurehome smart hub
broker: *hub ip*
username: *username*
password: *password*
Expand All @@ -57,11 +86,14 @@ mqtt:

### 2. Install add-on

1) Add this repo as an add-on repository
2) Install the addon 'Futurehome FIMP to MQTT'
3) Configure the addon with the same parameters as before
4) Start it. Supported devices should appear in the Home Assistant UI

1. Add this repo as an add-on repository
- Settings -> Add-ons -> Add-on store -> 3 dots in top right -> repositories -> paste link to this repository -> add
2. Install the addon 'Futurehome FIMP to MQTT'
- Select `Futurehome FIMP integration` in the Add-on store -> install
3. Configure the addon with the same parameters as before
- If you want to include or exclude certain devices, please specify with radio buttons, and then the devices in `selected_devices` with this format: \<adapter>\_\<address>. If you want to include all supported devices, leave radio button on `default`.
Devices without a room will be ignored.
4. Start it. Supported devices should appear in the Home Assistant UI

# Development

Expand All @@ -72,6 +104,7 @@ which provides a full Home Assistant setup.
## Using virtual env

### Git clone and installation

```
git clone https://github.com/runelangseid/hassio-futurehome2mqtt
cd hassio-futurehome2mqtt/futurehome2mqtt
Expand All @@ -84,64 +117,13 @@ pip install -r requirements.txt
### Configuration

1. Setup configuration
```
cp env-dist .env
```
```bash
cp env-dist .env
```
2. Edit `.env` and fill in hostnames and credentials

3. Run `source .env && python run.py serve`

3. Run `python run.py`

# Alternative FIMP integrations

Below are examples on how to add Wall plugs and sensors manually to Home Assistant
using MQTT without the use of this addon.

## Wall plug (Fibaro)

Replace '34' with the address for the device in Futurehome.

```
mqtt:
#
# Kontor
#
# Wall plug
switch:
- name: "Wall plug (kontor)"
state_topic: "pt:j1/mt:evt/rt:dev/rn:zw/ad:1/sv:out_bin_switch/ad:34_0"
command_topic: "pt:j1/mt:cmd/rt:dev/rn:zw/ad:1/sv:out_bin_switch/ad:34_0"
value_template: '{{ value_json.val }}'
payload_on: '{"props":{},"serv":"out_bin_switch","tags":[],"type":"cmd.binary.set","val":true,"val_t":"bool"}'
payload_off: '{"props":{},"serv":"out_bin_switch","tags":[],"type":"cmd.binary.set","val":false,"val_t":"bool"}'
state_on: true
state_off: false
```

## Multi Sensor (Fibaro)

Replace '37' with the address for the device in Futurehome.

```
mqtt:
# Fibaro Eye
sensor:
- name: "Batteri Kontor"
state_topic: "pt:j1/mt:evt/rt:dev/rn:zw/ad:1/sv:battery/ad:37_0"
unit_of_measurement: '%'
value_template: "{{ value_json.val }}"

- name: "Bevegelse Kontor"
state_topic: "pt:j1/mt:evt/rt:dev/rn:zw/ad:1/sv:sensor_presence/ad:37_0"
value_template: "{{ value_json.val }}"

- name: "Temperatur Kontor"
state_topic: "pt:j1/mt:evt/rt:dev/rn:zw/ad:1/sv:sensor_temp/ad:37_0"
unit_of_measurement: '°C'
value_template: "{{ value_json.val }}"

- name: "Lysstyrke Kontor"
state_topic: "pt:j1/mt:evt/rt:dev/rn:zw/ad:1/sv:sensor_lumin/ad:37_0"
unit_of_measurement: 'Lux'
value_template: "{{ value_json.val }}"
```
Look at [here](yaml_manual_examples.md) for examples on how to add Wall plugs and sensors manually in `configuration.yaml`, using MQTT without the use of this addon.
126 changes: 113 additions & 13 deletions futurehome2mqtt/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,121 @@
## 0.3.7

- Updated README
- Changed `selected_devices_mode` default option from 'ignored' to 'default' to include all supported devices.

## 0.3.6

- Added more sensors in meter_elec
- p_import
- e_import
- p_import_react
- p_export_react
- Added 'boiler' type as switch
- (dev) Some cleanup in meter_elec.py

## 0.3.5

- Added support for contact sensors
- Subtypes `door`, `window`, `garage` supported
- Added more checks on reports from sensors
- Added support to select if you want to include or excluding certain devices from being synced
- Move mode and shortcut to one device "Futurehome Smarthub"
- Updated README
- Support for contact sensor
- Describing the selected_devices in configuration
- (dev) Added symbolic link for README.md into `futurehome2mqtt` directory.
This allows the add-on store to show the content of README.md instead of nothing.
- (dev) Refactored client.py, and removed fimp.py
- (dev) Changed env variables to snake_case for readability
- (dev) Changed from `str` to `password` for fimp_password on configuration screen
- (dev) Added breaking_versions to config file
- (dev) Temporarily fixed debug option - verbose logging enabled if option is set to true.
Plan to use better logger with loglevels.
- (dev) Removed name from device object for sensor_temp.
This will prevent device name for Heatit z-trm3 to be overwritten with the sensor name

## 0.3.4

- Removed unused dependency 'requests'

## 0.3.3

- Added logo and icon
- Fixes: On some thermostats (e.g Heatit) you are currently not able to readout current
measured temperature (room temp sensor or floor temp sensor) directly on the thermostat card as it is on a different device.

Note that the temperature sensor that have the "Set as main temp sensor" checkbox checked in the Futurehome app will be used.

## 0.3.2

- Added basic HAN sensor support
- Updated README
- Clearer installation instructions
- Added 'Known issues' section

## 0.3.1

- Fixes: Fails to install on Home Assistant. Error: `The command '/bin/ash -o pipefail -c apk add --no-cache python3 py-pip && pip3 install --upgrade pip' returned a non-zero code: 1`
- (dev) moved devcontainer.json file to the recommended folder. Ref [docs](https://developers.home-assistant.io/docs/add-ons/testing/)

## 0.3.0

### Breaking changes

Note that version 0.3.x includes breaking changes from 0.2.x.
This is mainly due to the refactor to include adapter name in the identifiers, and how entities are grouped to one device.
You may have to update all entities in dashboards and automations etc.

### New, fixed, and improved:

- Huge code rewrite to be more adaptive
- Added basic lock/unlock for doorlocks. Tested with IDLock 150 (Unlock commands are currently not supported on Zigbee)
- Added thermostat support
- Set mode
- Set target temp
- Change fan speed if device supports it (e.g Sensibo)
- Added humidity sensor
- Fixed `meter_elec` service for accumulated energy usage (kWh)
- Expanded `meter_elec` service for devices that supports this:
- Power (W)
- Voltage (V)
- Current (A)
- Changed mode sensor to be a (dropdown) select, so you are able to switch mode
- Added shortcuts support
- Added room support
- Devices will be placed in rooms with the same names as Futurehome. If the room does not exist it will be created
- All devices now generate MQTT devices and group all common sensors and controls
- (dev) added .env file to be sourced with `python-dotenv`

### Planned and work in progress:

- HAN sensor support
- On some thermostats (e.g Heatit) you are currently not able to readout current
measured temperature (room temp sensor or floor temp sensor) directly on the thermostat card as it is on a different device
- Fails to install on Home Assistant. Error: `The command '/bin/ash -o pipefail -c apk add --no-cache python3 py-pip && pip3 install --upgrade pip' returned a non-zero code: 1`

### Known issues:

- Some devices might still use sensor_power (deprecated) and sensor_voltage (deprecated) instead of `meter_elec`

## 0.2.2

* Added mode sensor as `sensor.fh_mode` (home, away, sleep, vacation). Read only
- Added mode sensor as `sensor.fh_mode` (home, away, sleep, vacation). Read only

## 0.2.1

* Added presence sensors
- Added presence sensors

## 0.2

* Huge code rewrite. Code base has been reduced
* Most things from 0.1 should work
* Dimmers for lightning
* Binary switches for appliances and lightning
* Sensors: battery, illuminance, temperature, electric meters
* Modus switch is not re-implemented yet
* Internal bridge for Dimmer lights have been removed, reducing complexity in addon
* Entities are now generated based on device id Futurehome and not the name using `object_id`
* Simplified configuration. No need for long-lived token and uptime sensor as HA announces restarts via MQTT
* Rewritten MQTT discovery
* Added Energy sensor for all devices which supports this (´meter_elec`)
- Huge code rewrite. Code base has been reduced
- Most things from 0.1 should work
- Dimmers for lightning
- Binary switches for appliances and lightning
- Sensors: battery, illuminance, temperature, electric meters
- Modus switch is not re-implemented yet
- Internal bridge for Dimmer lights have been removed, reducing complexity in addon
- Entities are now generated based on device id Futurehome and not the name using `object_id`
- Simplified configuration. No need for long-lived token and uptime sensor as HA announces restarts via MQTT
- Rewritten MQTT discovery
- Added Energy sensor for all devices which supports this (´meter_elec`)
Loading