As a cross border commuter I need to file my whereabouts every year to both the tax agencies in both the country of residence and the country I work in. My thought was that it may be possible to automate in HA, since it already has my tracking.
I found the File integration, which I would like to write to a log file, whenever my Person enters some predefined Zones in my working country. All the rest working days will be assumed working from my country of residence.
My goal would be to:
Trigger when my person has been in a zone for more than 4 hours
Write the log to a File: timestamp and name of zone
I tried to write an automation, but this is a bit over my current knowledge to get it to work.
alias: Whereabout
description: ''
trigger: // not sure how to add the minimum time in a specific zone
- platform: zone
entity_id: person.john_doe
zone: zone.work_office_a
event: enter
- platform: zone
entity_id: person.john_doe
zone: zone.work_office_b
event: enter
condition: []
action:
- service: notify.john_does_whereabout //Using the File integration
data:
message: '{{person.john_doe}}' //Not sure how to fetch the persons current zone name as variable?
mode: single
Anyone able to help me getting this automation progressed? Or does there exist better ways of doing so? All input is appreciated thanks.
Hi, being a cross-boarding person too… this data will not be accepted by the authorities as this is not formally accepted as a source of truth and (you do know this) this can be manipulated easily.
If you only want it for reporting, the data can be stored in a long-term db (e.g. influx) and used for reporting from their on…check e.g. for influx in other posts
EDIT: I cross French-Swiss boarder and never needed to prove my whereabouts…which country is asking you to do so?
I believe here they are satisfied with somekind of “statement of truth” here. I’m crossing Denmark and Sweden. Sweden asked for prove on my tax year 2020 they accepted an excel sheet template made by Danish tax authorities, which was based on my own excel sheet extracted from Google Maps.
Luckily Google Maps tracked all my locations when I needed it, at that time, but it also worried me what they logged so much, so I turned off Maps tracking. Instead I will use my HA.
Sounds as a good idea to use Influx. Actually I did install it for some month ago for other reasons, but seems like it’s worth take a look into how it can solve my use case.
I use an Automation to log my daily/monthly energy usage to a CSV file via a file notify group, I think you should be able to achieve what you want using this technique with the triggers you have defined above.
I have setup reporting for my AC/Heating so that it does something similar to what you’re trying to achieve, I guess.
It measures how long both of my AC/Heating zones are running throughout the day and adds this info to the end of a csv file at midnight.
In order to do that I set up a few sensors, which I think could be replicated with location info/zones.
#######################################################################
# Turn 'fan on' into true/false for stats
#######################################################################
- platform: template
sensors:
s_w_fanon4stats:
value_template: >-
{%- if states.climate.s_w_thermostat.attributes.hvac_action == 'heating' -%}
true
{%- elif states.climate.s_w_thermostat.attributes.hvac_action == 'cooling' -%}
true
{%- else -%}
false
{%- endif -%}
- platform: template
sensors:
l_e_fanon4stats:
value_template: >-
{%- if states.climate.l_e_thermostat.attributes.hvac_action == 'heating' -%}
true
{%- elif states.climate.l_e_thermostat.attributes.hvac_action == 'cooling' -%}
true
{%- else -%}
false
{%- endif -%}
#######################################################################
# Since Midnight Fan Stats
#######################################################################
- platform: history_stats
name: S&W Fan On Since Midnight in h
entity_id: sensor.s_w_fanon4stats
state: 'true'
type: time
start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
end: '{{ now() }}'
- platform: history_stats
name: L&E Fan On Since Midnight in h
entity_id: sensor.l_e_fanon4stats
state: 'true'
type: time
start: '{{ now().replace(hour=0).replace(minute=0).replace(second=0) }}'
end: '{{ now() }}'
The above could probably be easily adjusted to how long you are in a specific zone.
The below is the definition of the notification method in my configuration.yaml: