Comments (9)
If you are using Home Assistant you can achieve the same result using an input_number and an automation i.e.
sensor
- platform: mqtt
state_topic: 'home/BLETracker/FFEEDDCCBBAA'
name: 'nut_battery'
value_template: "{{ value_json.battery|int }}"
force_update: true
input_number:
battery_value:
name: BatteryValue
min: -1
max: 100
unit_of_measurement: "%"
automation
- id: update_nut_battery
alias: update_nut_battery
initial_state: true
trigger:
platform: state
entity_id: sensor.nut_battery
condition:
condition: numeric_state
entity_id: sensor.nut_battery
above: -1
action:
service: input_number.set_value
target:
entity_id: input_number.battery_value
data:
value: "{{ states('sensor.nut_battery')}}"
Hope this can help
Best regards
from esp32_bletracker.
Hi,
you can use a rest sensor to retrieve the information you need. Unfortunately there is a bug in the current released version preventing the rest sensor to work, but I have fixed it in the develop branch ( PR #48 )
sensor:
- platform: rest
resource: http://<bletracker_ip>/getsysinfodata
name: LastBatteryReading
value_template: >-
{% if value_json.devices | length > 0 %}
{% for x in value_json.devices %}
{% if x.mac == "AABBCCDDEEFF"%}
{{x.bttime}}
{%endif%}
{% endfor %}
{% endif %}
You should improve the template to check for missing bttime field in order to avoid error.
from esp32_bletracker.
Hi, sorry but I don't see the usefulness of this feature. If the device is away from home, an untrue data would be reported; from the panel you could read that the device is charged, when instead it could be completely discharged. In this case, in my opinion, it is more appropriate to report an unknown status (-1), which happens even if the ESP does not reset and the device is not found when the battery reading timeout is triggered.
from esp32_bletracker.
Hi,
having found myself several times in the situation of being away from home with the ESP restarted, I can confirm that having the last data on the battery, now that the date and time of the last detection is also displayed, is useful.
Could you find a meeting point and display the last battery level (with the detection date) with the (-1) next to it so you understand that it is not certain?
Thanks again for the great job done
from esp32_bletracker.
Thanks!
from esp32_bletracker.
Hi Mario,
having the data in MQTT, would it be possible to pass to HA also the date and time of the last battery detection, without having to change the firmware on the ESP?
Thanks in advance
from esp32_bletracker.
Thank you BIG Mario!
from esp32_bletracker.
Hi,
you can use a rest sensor to retrieve the information you need. Unfortunately there is a bug in the current released version preventing the rest sensor to work, but I have fixed it in the develop branch ( PR #48 )sensor: - platform: rest resource: http://<bletracker_ip>/getsysinfodata name: LastBatteryReading value_template: >- {% if value_json.devices | length > 0 %} {% for x in value_json.devices %} {% if x.mac == "AABBCCDDEEFF"%} {{x.bttime}} {%endif%} {% endfor %} {% endif %}
You should improve the template to check for missing bttime field in order to avoid error.
Thanks again Mario for the work done.
Place the perfectly working code:
sensor:
- platform: rest
resource: http://<bletracker_ip>/getsysinfodata
name: LastDateBatteryReading
username: "username"
password: "password"
authentication: basic
headers:
User-Agent: Home Assistant
Content-Type: application/json
value_template: >-
{% if value_json.devices | length > 0 %}
{% for x in value_json.devices %}
{% if x.mac == "AABBCCDDEEFF"%}
{% if x.bttime is defined %}
{{x.bttime | timestamp_local}}
{%else%}
0
{%endif%}
{% endif %}
{% endfor %}
{%endif%}
device_class: timestamp
input_number:
battery_number:
name: battery_inputnumber
min: -1
max: 100
unit_of_measurement: "%"
input_datetime:
battery_datetime:
name: battery_datetime
has_date: true
has_time: true
automation:
- id: update_nut_battery
alias: update_nut_battery
trigger:
platform: state
entity_id: sensor.lastdatebatteryreading
condition:
condition: numeric_state
entity_id: sensor.nut_battery
above: -1
action:
service: input_number.set_value
target:
entity_id: input_number.battery_number
data:
value: "{{ states('sensor.nut_battery')}}"
- id: update_datetime_nut_battery
alias: update_datetime_nut_battery
trigger:
platform: state
entity_id: sensor.lastdatebatteryreading
condition:
condition: template
value_template: "{{as_timestamp(states('sensor.lastdatebatteryreading')) > 0}}"
action:
service: input_datetime.set_datetime
target:
entity_id: input_datetime.battery_datetime
data:
timestamp: "{{as_timestamp(states('sensor.lastdatebatteryreading'))}}"
from esp32_bletracker.
I suppose I can close this issue.
from esp32_bletracker.
Related Issues (20)
- FHEM support request HOT 16
- Add the capability to set a static IP
- FHEM Mode exceptions HOT 49
- Friendly name to the MAC address HOT 2
- MAX_NON_ADV_PERIOD in control panel HOT 3
- Retain State and Battery level after black-out HOT 2
- Wrong time reported in the logs HOT 2
- Report the date and time of the last battery level detection HOT 2
- BLE Tracker HOT 13
- New firmware release notification HOT 2
- Multiple esp32 network HOT 4
- Noob needs help HOT 2
- Running extremely slow? HOT 3
- Build problem HOT 7
- Implement a Mailbox Sensor,Led and MQTT message HOT 4
- only battery state ? HOT 2
- reset HOT 7
- Settings via the web interface HOT 6
- The status of the gateway is unstable HOT 12
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esp32_bletracker.