-
Notifications
You must be signed in to change notification settings - Fork 21
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
Integrating with Home Assistant #57
Comments
+1 |
2 similar comments
+1 |
+1 |
You could also use existing RESTful integration if you want to add PM sensors to Home Assistant. Example: sensor:
- name: Klimerko PM2.5
unique_id: klimerko_pm2_5
platform: rest
resource: https://api.allthingstalk.io/asset/<ASSET_ID>
headers:
Authorization: !secret att_maker_api_token
Content-Type: application/json
device_class: pm25
unit_of_measurement: µg/m³
icon: mdi:molecule
json_attributes_path: "$.state"
json_attributes:
- at
value_template: "{{ value_json.state.value }}" |
Has it worked for anyone? |
Solved, it works. In the authorization line, add Bearer and then token. |
In my case
att_maker_api_token: "Bearer maker:<TOKEN>" @rajkoc you should always tend to store secrets in secrets.yaml file. |
I have also created a more comprehensive configuration that use RESTful instead of RESTful Sensor integration. You only need to replace
rest:
# Klimerko
- resource: https://api.allthingstalk.io/device/<DEVICE_ID>
method: GET
headers:
Authorization: !secret att_maker_api_token
Content-Type: application/json
scan_interval: 60
sensor:
# PM1 sensor
- name: Klimerko PM1
unique_id: klimerko_pm1
device_class: pm1
unit_of_measurement: "µg/m³"
icon: mdi:molecule
json_attributes_path: "$.assets[?(@.name=='pm1')].state"
json_attributes:
- at
value_template: |
{% set sensor = value_json.assets | selectattr("name", "eq", "pm1") | first | default %}
{{- sensor.state.value }}
# PM2.5 sensor
- name: Klimerko PM2.5
unique_id: klimerko_pm2_5
device_class: pm25
unit_of_measurement: "µg/m³"
icon: mdi:molecule
json_attributes_path: "$.assets[?(@.name=='pm2-5')].state"
json_attributes:
- at
value_template: |
{% set sensor = value_json.assets | selectattr("name", "eq", "pm2-5") | first | default %}
{{- sensor.state.value }}
# PM10 sensor
- name: Klimerko PM10
unique_id: klimerko_pm10
device_class: pm10
unit_of_measurement: "µg/m³"
icon: mdi:molecule
json_attributes_path: "$.assets[?(@.name=='pm10')].state"
json_attributes:
- at
value_template: |
{% set sensor = value_json.assets | selectattr("name", "eq", "pm10") | first | default %}
{{- sensor.state.value }}
# Temperature sensor
- name: Klimerko Temperature
unique_id: klimerko_temperature
device_class: temperature
unit_of_measurement: "°C"
icon: mdi:thermometer
json_attributes_path: "$.assets[?(@.name=='temperature')].state"
json_attributes:
- at
value_template: |
{% set sensor = value_json.assets | selectattr("name", "eq", "temperature") | first | default %}
{{- sensor.state.value }}
# Humidity sensor
- name: Klimerko Humidity
unique_id: klimerko_humidity
device_class: humidity
unit_of_measurement: "%"
icon: mdi:water-percent
json_attributes_path: "$.assets[?(@.name=='humidity')].state"
json_attributes:
- at
value_template: |
{% set sensor = value_json.assets | selectattr("name", "eq", "humidity") | first | default %}
{{- sensor.state.value }}
# Atmospheric Pressure sensor
- name: Klimerko Atmospheric Pressure
unique_id: klimerko_atmospheric_pressure
device_class: atmospheric_pressure
unit_of_measurement: "mbar"
icon: mdi:gauge
json_attributes_path: "$.assets[?(@.name=='pressure')].state"
json_attributes:
- at
value_template: |
{% set sensor = value_json.assets | selectattr("name", "eq", "pressure") | first | default %}
{{- sensor.state.value }} |
Thank you very much Miloš. Works great! |
This works fine when it has internet access. It's still not a solution to the problem. IMO Klimerko should have local integration with home assistant, whole point of smart home is that it works without internet access too. |
So isn't the point of sharing with the community? |
@DjordjeMandic I couldn't agree more, still at this very moment this is all we got. 😞 Also Klimerko firmware is using pub/sub model (MQTT protocol), thus sensor data are published to public broker's endpoint, so one way on how you can generate local data w/o Internet access is by provisioning a local broker (e.g. Mosquitto + MQTT Sensor) and by modifying default broker endpoint to use local broker address where sensor and diagnostic data will be published. |
It is, my intention was never to move it to local only. My intention is to have it do its job like it is now and besides that publish data to HA also. My idea was to expose sensors to HA directly via HA API or use one more MQTT connection. If anyone is willing to contribute we can implement the following:
Exposed stuff would include:
|
One addition this approach provides is you can basically add any device that is registered and shared on the AllThingsTalk platform to HomeAssistant, not only devices that you own. You just need to pick a shared |
It would be great to have all these features implemented, the only concern I have, not saying it's justifiable, is that I don't know if this hardware (ESP8266 board) has sufficient amount of resources to support all that and how well and reliable it will work. |
RAM is limit here. ArduinoJson will be biggest issue but it all can be managed with proper memory allocation and code layout to prevent fragmentation as much as possible. Rest can be managed with freertos (should have been from the start imo when there is multiple services running). |
@DjordjeMandic thank you for detailed explanation. |
Just a suggestion, when its already on the network mdns discovery should be implemented and home asstiant integration made for it.
The text was updated successfully, but these errors were encountered: