-
Notifications
You must be signed in to change notification settings - Fork 24
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. |
If anyone is interested, I’ve also created a mini-graph-card that can be used with Klimerko entities. type: vertical-stack
cards:
- type: custom:mini-graph-card
name: Outdoor
entities:
- entity: sensor.klimerko_temperature
name: Temperature
show_state: true
state_adaptive_color: true
aggregate_func: max
- entity: sensor.klimerko_humidity
name: Humidity
show_state: true
state_adaptive_color: true
show_line: false
show_points: true
show_legend: true
color: "#2AD4FF"
y_axis: secondary
aggregate_func: avg
color_thresholds:
- value: -40
color: "#2AD4FF"
- value: 16
color: "#FFA500"
- value: 29
color: "#E53935"
line_width: 4
font_size_header: 13
font_size: 70
hours_to_show: 24
points_per_hour: 3
hour24: true
animate: true
show:
icon: false
fill: true
labels: true
labels_secondary: true
- type: custom:mini-graph-card
name: Outdoor PM10
entities:
- entity: sensor.klimerko_pm10
show_state: true
state_adaptive_color: true
font_size_header: 13
font_size: 70
aggregate_func: avg
decimals: 0
hours_to_show: 24
points_per_hour: 2
line_width: 4
color_thresholds:
- value: 0
color: "#17a355"
- value: 54
color: "#e9d109"
- value: 154
color: "#ff8c00"
- value: 254
color: "#ea270d"
- value: 354
color: "#7c2c85"
- value: 424
color: "#66001f"
animate: true
hour24: true
show:
graph: bar
labels: true
average: true
extrema: true
icon: false
- type: custom:mini-graph-card
name: Outdoor PM2.5
entities:
- entity: sensor.klimerko_pm2_5
show_state: true
state_adaptive_color: true
font_size_header: 13
font_size: 70
aggregate_func: avg
decimals: 0
hours_to_show: 24
points_per_hour: 2
line_width: 4
color_thresholds:
- value: 0
color: "#17a355"
- value: 12
color: "#e9d109"
- value: 35
color: "#ff8c00"
- value: 55
color: "#ea270d"
- value: 150
color: "#7c2c85"
- value: 250
color: "#66001f"
animate: true
hour24: true
show:
graph: bar
labels: true
average: true
extrema: true
icon: false The final result will look something like this: |
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: