-
Notifications
You must be signed in to change notification settings - Fork 16
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
Add Attributes to a sensor device #27
Comments
Maybe this could be implemented similar to the For example, instead of generating five separate sensor for the same printer # Dell Printer
multiscrape:
- resource: !secret printer_status
scan_interval: 900
sensor:
- name: Printer Toner Level Cyan
select: "body > table > tr > td > table:nth-child(6) > tr > td > table > tr:nth-child(2) > td:nth-child(1) > b"
value_template: '{{ value|regex_findall_index(find="(\d+)\%", index=0, ignorecase=False) }}'
unit_of_measurement: "%"
- name: Printer Toner Level Magenta
select: "body > table > tr > td > table:nth-child(6) > tr > td > table > tr:nth-child(4) > td:nth-child(1) > b"
value_template: '{{ value|regex_findall_index(find="(\d+)\%", index=0, ignorecase=False) }}'
unit_of_measurement: "%"
- name: Printer Toner Level Yellow
select: "body > table > tr > td > table:nth-child(6) > tr > td > table > tr:nth-child(6) > td:nth-child(1) > b"
value_template: '{{ value|regex_findall_index(find="(\d+)\%", index=0, ignorecase=False) }}'
unit_of_measurement: "%"
- name: Printer Toner Level Black
select: "body > table > tr > td > table:nth-child(6) > tr > td > table > tr:nth-child(8) > td:nth-child(1) > b"
value_template: '{{ value|regex_findall_index(find="(\d+)\%", index=0, ignorecase=False) }}'
unit_of_measurement: "%"
- resource: !secret printer_volume
scan_interval: 900
sensor:
- name: Printer Volume
select: "body > table > tr > td > table:nth-child(4) > tr > td > table > tr > td:nth-child(2) > font"
value_template: '{{ value }}'
unit_of_measurement: "pages" it could be one sensor with a state for the number of pages and four attributes for toner levels. Maybe similar to this: # Dell Printer
multiscrape:
- sensor:
name: Dell Printer
value:
- resource: !secret printer_volume
scan_interval: 900
name: Printer Volume
select: "body > table > tr > td > table:nth-child(4) > tr > td > table > tr > td:nth-child(2) > font"
value_template: '{{ value }}'
unit_of_measurement: "pages"
attributes:
- name: Toner Level Cyan
resource: !secret printer_status
scan_interval: 900
select: "body > table > tr > td > table:nth-child(6) > tr > td > table > tr:nth-child(2) > td:nth-child(1) > b"
value_template: '{{ value|regex_findall_index(find="(\d+)\%", index=0, ignorecase=False) }}'
- name: Toner Level Magenta
resource: !secret printer_status
scan_interval: 900
select: "body > table > tr > td > table:nth-child(6) > tr > td > table > tr:nth-child(4) > td:nth-child(1) > b"
value_template: '{{ value|regex_findall_index(find="(\d+)\%", index=0, ignorecase=False) }}'
- name: Toner Level Yellow
resource: !secret printer_status
scan_interval: 900
select: "body > table > tr > td > table:nth-child(6) > tr > td > table > tr:nth-child(6) > td:nth-child(1) > b"
value_template: '{{ value|regex_findall_index(find="(\d+)\%", index=0, ignorecase=False) }}'
- name: Toner Level Black
resource: !secret printer_status
scan_interval: 900
select: "body > table > tr > td > table:nth-child(6) > tr > td > table > tr:nth-child(8) > td:nth-child(1) > b"
value_template: '{{ value|regex_findall_index(find="(\d+)\%", index=0, ignorecase=False) }}' |
how to release read attr paremeter?
|
I realise that my example might be too complicated as it has several calls to different resources for one sensor. But in your example, how would you set state and more than one attribute to one sensor from the one resource? |
What about this: multiscrape:
- resource: !secret pwr_sw_address
username: !secret pwr_sw_username
password: !secret pwr_sw_password
scan_interval: 5
sensor:
- name: relay_1
select: "button[name=relayon1] ~ img"
value_template: '{{ value.split("light")[1].split(".jpg")[0] }}'
attributes:
- name: src
select: "some selection"
value_template: "some value template"
- name: brand
select: "some selection"
value_template: "some value template"
- name: model
select: "some selection"
value_template: "some value template" So from one resource you get one or more sensors with states and each sensor can have several attributes with their own selections in addition to the state. |
And how do I get the sensor value then? |
Yes, that would be the idea. You have one main value representing the sensor. But then this sensor also has a number of additional attributes that come along with it. |
Today is not work. |
Adding attributes in this way is indeed how I envision it. |
@wcomartin thank you for your patience! Please check pre-release v4.1.0! PS: And thank you for initiating the Kia Uvo integration :) |
ok, will check, thanks currently, with the latest 2021.6.4 multiscrape is broken for me. The previously working sensors stopped working. I'll try the pre-release and will report back and if the problem still exists open a separate issue. |
Hm, I'm not entirely sure how the attributes are supposed to work. I tried this: multiscrape:
- resource: !secret printer_status
scan_interval: 900
sensor:
- name: Printer Toner Level
value_template: '{{ value }}'
select: "body > table > tr > td > table:nth-child(10) > tr > td > table > tr:nth-child(2) > td:nth-child(2) > b"
attributes:
- name: Cyan
select: "body > table > tr > td > table:nth-child(6) > tr > td > table > tr:nth-child(2) > td:nth-child(1) > b"
value_template: '{{ value|regex_findall_index(find="(\d+)\%", index=0, ignorecase=False) }}'
- name: Magenta
select: "body > table > tr > td > table:nth-child(6) > tr > td > table > tr:nth-child(4) > td:nth-child(1) > b"
value_template: '{{ value|regex_findall_index(find="(\d+)\%", index=0, ignorecase=False) }}'
- name: Yellow
select: "body > table > tr > td > table:nth-child(6) > tr > td > table > tr:nth-child(6) > td:nth-child(1) > b"
value_template: '{{ value|regex_findall_index(find="(\d+)\%", index=0, ignorecase=False) }}'
- name: Black
select: "body > table > tr > td > table:nth-child(6) > tr > td > table > tr:nth-child(8) > td:nth-child(1) > b"
value_template: '{{ value|regex_findall_index(find="(\d+)\%", index=0, ignorecase=False) }}' and I get the following error:
|
Thanks, data is arriving well now. But there is still a bug - I'll file a new issue... |
Thanks for testing!
|
You guys are awesome!! This is going to make my modem status scraping much simpler. |
Would be really cool to have the ability to add attributes from the scrape to the sensor as well as have multiple sensors
for example if the webpage had a table of data, and you wanted other columns in the table to be attributes.
The text was updated successfully, but these errors were encountered: