Fingbox without IFTTT

If you like me dont want to have your Home-Assistant exposed outside your network and still want to use your fingbox for presence detection.

Then there is another way to “pull” your status and not use the IFTTT sollution.

Use the same settings to setup ‘alert me when state changes’ as described here

Then use the imap component in HA to “pull” the state.
To keep my inbox clean i have setup a separate mailbox for my fingbox ([email protected])
I store the state in mqtt to make it persistent.

I find this way to use fingbox for presence a bit faster then the IFTTT way.
Hopefully Fingbox will get a native API soon that will work with HA for a super fast detection.

############################################################################
## IMAP - Fing
############################################################################
## Customizations
############################################################################
homeassistant:
  customize:
    sensor.fing_state:
      hidden: true

    sensor.fing_matte:
      entity_picture: /local/fing.png
############################################################################
## Sensor
############################################################################
sensor:
#---------------------------------------------------------------------------
  - platform: imap_email_content
    name: Fing State
    server: imap.gmail.com
    port: 993
    username: !secret imap_email_content_username
    password: !secret imap_email_content_password
    senders:
      - [email protected]
    value_template: subject
############################################################################
## Automations
############################################################################
automation:
  - alias: 'Matte fing DOWN'
    initial_state: 'on'
    trigger:
      - platform: state
        entity_id: sensor.fing_state
    condition:
      condition: and
      conditions:
        - condition: template
          value_template: "{{ states.sensor.fing_state.attributes.subject == 'A device went DOWN: Mattes Mobil @ McFrojd' }}"
    action:
      - service: mqtt.publish
        data:
          topic: 'fing/matte'
          payload_template: 'Away'
          retain: True
#---------------------------------------------------------------------------
  - alias: 'Matte fing UP'
    initial_state: 'on'
    trigger:
      - platform: state
        entity_id: sensor.fing_state
    condition:
      condition: or
      conditions:
        - condition: template
          value_template: "{{ states.sensor.fing_state.attributes.subject == 'A device went UP: Mattes Mobil @ McFrojd' }}"
        - condition: template
          value_template: "{{ states.sensor.fing_state.attributes.subject == 'A device is IN RANGE: Mattes Mobil @ McFrojd' }}"
    action:
      - service: mqtt.publish
        data:
          topic: 'fing/matte'
          payload_template: 'Home'
          retain: True
2 Likes

@mcfrojd Thanks for this, I used it to setup some automations so that I do not need to use IFTTT. I wanted to update the status of multiple device trackers, so my automation looks a bit different than yours and thought I would share it here.

My configuration.yaml looks just like yours, except without the “value_template: subject” as it was just filling in “subject”

######################################################
## IMAP - Fing
######################################################
## Customizations
######################################################
homeassistant:
  customize:
    sensor.fing_state:
      hidden: true

######################################################
## Sensor
######################################################
sensor:
#-----------------------------------------------------
  - platform: imap_email_content
    name: Fing State
    server: imap.gmail.com
    port: 993
    username: !secret imap_email_content_username
    password: !secret imap_email_content_password
    senders:
      - [email protected]

My automations look like this:

######################################################
## Automations
######################################################
automation:
  - alias: 'Fing update user'
    initial_state: true
    trigger:
      platform: state
      entity_id: sensor.fing_state
    action:
      service: device_tracker.see
      data_template:
        dev_id: '{{ (trigger.to_state.state.split(": ")[1]).split(" ")[0]}}'
        location_name: >-
          {% if trigger.to_state.state.split(": ")[0] == 'Offline' %} not_home
          {% elif trigger.to_state.state.split(": ")[0] == 'In range' or trigger.to_state.state.split(": ")[0] == 'Online' %} home
          {% endif %}

The imap component defaults to putting the subject of the email as the state. The format of the fing email subjects that I am receiving look like this:

Online: device1_fing @ YourNetwork 
  or
In range: device1_fing @ YourNetwork
  or
Offline: device1_fing @ YourNetwork

These are easy to parse, and I use it to figure out the device and the state in the data_template of the automation above.

I name my devices in the fing app (or on app.fing.io) to names like device1_fing, device2_fing, etc. The automation will make entries into your known_devices.yaml, or you can make some entries of your own:

device1_fing:
  hide_if_away: true
  icon:
  mac:
  name: device1_fing
  picture:
  track: true

I have my users in groups for tracking presence, so I just add this new device to the group for the correct user and all my automations based around users are already using those groups.

I noticed that the imap component was reading all the email in the in box after restarting HA, so I made a mail rule in my inbox to delete email that are more than one day old so that the component doesn’t have to read all the email and cycle the state of all the devices as it rolls through all the email.

When i try your setup i get this error:
2018-08-08 02:14:12 ERROR (MainThread) [homeassistant.helpers.service] Error rendering data template: UndefinedError: 'trigger' is undefined

Strange because the trigger is right there in the automation. I have my automations split out into a separate file, but that shouldn’t make and difference.

I am running the latest version of HA.

I’d really like to get something like this going, I love my Fingbox and it seems very accurate for presence detection. I just don’t think that I’m smart enough to figure out what pieces of code should stay at listed above and what needs to be changed for my configuration in using 2, possibly 3 trackers. I sure hope that they release an API to make it easier.

If you use Gmail you should only need to set your email username and password in your secrets.yaml file and the example from @GervaisdeM should work.

Really?? That would be great, I have to give it a shot soon, thanks

What I do is have multiple trackers for devices and then put them in a group. Any one of the device trackers sets the group to “home” if it is home.

You can check out my configs on github.

My group.yaml has stuff like this in it:

gervais_tracker:
  entities:
    - device_tracker.iphone_2
    - device_tracker.gervais_iphonehass
    - device_tracker.gervais_iphonetracks
    - device_tracker.gervais3
    - device_tracker.gervais_fing

Then I have all my automations fire using the state of group.gervais_tracker. Something like this:

- alias: 'GandG not home - turn off bedroom things'
  initial_state: true
  trigger:
    - platform: state
      entity_id: group.gail_tracker
      from: 'home'
    - platform: state
      entity_id: group.gervais_tracker
      from: 'home'
  condition:
    condition: and
    conditions:
      - condition: state
        entity_id: group.gail_tracker
        state: 'not_home'
      - condition: state
        entity_id: group.gervais_tracker
        state: 'not_home'
  action:
    service: light.turn_off
    entity_id: group.bedroom_lights

Thanks, I think that this will give me a good base and help me in trying to configure this.

I think that what I am missing and don’t quite understand, is how your automation “Fing update user” grabs the state of Person 1 - Tracker Phone 1 and also track Person 2 - Tracker Phone 2. And what gets updated to show the state of fing presence for Person 1 and also the presence of Person 2 …

Lastly, just to be clear, can this piece of code be entered in the customize.yaml file?

sensor.fing_state:
hidden: true

Thanks

I think this could… I don’t have a customiz.yaml file, so I have it in my configuration.yaml

This is done in the data_template part of the automation… After you setup the

  - platform: imap_email_content
    name: Fing State
    [...]

You should be able to see the value of the state by browsing to https://<your.ha.domain>/dev-template/ and then remove all the same input from the template editor… Replace everything there with this:

This is the subject of the email as saved in the state of the fing_state imap sensor:
    {{ states.sensor.fing_state.state }}

This is the same thing split out:
    {{ states.sensor.fing_state.state.split(": ")[0] }}
    {{ (states.sensor.fing_state.state.split(": ")[1]).split(" ")[0]}}

If not email has been received from fingbox yet, then the value will be blank from the sensor as it has not been populated yet. But if it is, you will see the output on the right hand side with something like this:

This is the subject of the email as saved in the state of the fing_state imap sensor:
    Offline: device1_fing @ HouseOfNine

This is the same thing split out:
    Offline
    device1_fing

The data_template part of the automation is using:

 {{ (trigger.to_state.state.split(": ")[1]).split(" ")[0] }}
  and 
 {% if trigger.to_state.state.split(": ")[0] == 'Offline' %} not_home

But those are essentially the same thing as the trigger is being triggered by the state change of sensor.fing_state

Allright, I think that I am following this a little better.
I think that the best thing wold be for me to give it a shot and see what happens. Thanks

Did you ever sort this out? You try doing a config check to see if there is an error in the configs? Perhaps a copy/pasta error?

The error seem to come only when i manually trigger the automation from frontend, not when it run automatically.

Today with v 0.81.2 i get a

WARNING (MainThread) [homeassistant.core] Unable to find service device_tracker/see

And my fing device_trackers are gone.
Any one else having same problem?

No issues for me here.

Is it possible that a typo was introduced into your automation? There shouldn’t be a “/” in there.
device_tracker.see not device_tracker/see

The “/” is only in the error message in the log, not in the automation.

2018-11-05 12:10:53 WARNING (MainThread) [homeassistant.core] Unable to find service device_tracker/see

automation:
  - alias: 'Fing update user'
    initial_state: true
    trigger:
      platform: state
      entity_id: sensor.fing_state
    action:
      service: device_tracker.see
      data_template:
        dev_id: '{{ (trigger.to_state.state.split(": ")[1]).split(" ")[0]}}'
        location_name: >-
          {% if trigger.to_state.state.split(": ")[0] == 'Offline' %} not_home
          {% elif trigger.to_state.state.split(": ")[0] == 'In range' or trigger.to_state.state.split(": ")[0] == 'Online' %} home
          {% endif %}

Your config looks identical to mine. I’m running 0.81.6. Perhaps the error was fixed in an update?

Fing changed the format of their emails which required some changes.

The email subjects are now using the name of the person that the device you are tracking is associated with.
Example:

Gervais is at <wifi-name>
Gervais left <wifi-name>

automations require an update.

######################################################
## Automations
######################################################
automation:
  - alias: 'Fing update user'
    initial_state: true
    trigger:
      platform: state
      entity_id: sensor.fing_state
    action:
      service: device_tracker.see
      data_template:
        dev_id: '{{ trigger.to_state.state.split(" ")[0] }}'
        location_name: >-
          {% if trigger.to_state.state.split(" ")[1] == 'left' %} not_home
          {% else %} home
          {% endif %}

known_devices.yaml now requires an entry based on the person’s name now.

gervais:
  hide_if_away: false
  icon:
  mac:
  name: Gervais - Fing
  picture:
  track: true

groups.yaml also has to use the new device_tracker.name format. My “fing” user is now showing up as device_tracker.gervais

gervais_tracker:
  entities:
    - device_tracker.gervais
    - device_tracker.gervais_iphonetracks
    - device_tracker.gervais3

I’m switching to ui-lovelace.yaml, so I don’t need the customizations that I previously setup to hide these entries, so I simply removed them.

The changes above can be seen in my github repo

My email subjects still says
Online: XXX @
Offline: XXX @
In range XXX @

Im using the latest app version and Fingbox ver 1.11.9

<sigh>

Well… Not sure why it changed for me. It might be because I have all the devices I am tracking associated with people.

@mcfrojd did you sort out your previous error?