Built a reminder sensor for automation

I found that reminder apps on my phone would only allow 1 geofence per reminder. this didnt work for me because I wanted to tag several locations and have a reminder go off at any one of those points without having multiple copies of it.

since home assistant allows me to give multiple zones the same name I desided to create a reminder app for it.

please keep in mind I have no experience coding so this might not spectacular but it works.

firstly you will need an app on your phone called TaskAgent. It is a simple reminder app that stores in plain text files and can sync them to a dropbox which you will also need as well as a way to sync it to your server.

then I made 2 lists called Store and Home.

next I created a file called reminders.py in the .homeassistant\custom_components\sensor directory

from homeassistant.helpers.entity import Entity
file1 = '/path_to_your_local/Dropbox/Apps/TaskAgent/Store.txt'
file2 = '/path_to_your_local/Dropbox/Apps/TaskAgent/Home.txt'


def setup_platform(hass, config, add_devices, discovery_info=None):
    """Setup the sensor platform."""
    add_devices([storelist()]) 
    add_devices([storeliston()])
    add_devices([homelist()]) 
    add_devices([homeliston()])
    
class storeliston(Entity):
    """Representation of a Sensor."""

    @property
    def name(self):
        """Return the name of the sensor."""
        return 'store_liston'

    @property
    def state(self):
        """Return the state of the sensor."""
        
        return None

    


class storelist(Entity):
    """Representation of a Sensor."""

    @property
    def name(self):
        """Return the name of the sensor."""
        return 'store_list'

    @property
    def state(self):
        """Return the state of the sensor."""
        f = open(file1)
        file = f.read()
        f.close()
        if not file:
            fstate = 'empty'
            storeliston.state = 'off'
        else:
            fstate = file
            storeliston.state = 'on'
             
        return fstate

class homeliston(Entity):
    """Representation of a Sensor."""

    @property
    def name(self):
        """Return the name of the sensor."""
        return 'home_liston'

    @property
    def state(self):
        """Return the state of the sensor."""
        
        return None


    


class homelist(Entity):
    """Representation of a Sensor."""

    @property
    def name(self):
        """Return the name of the sensor."""
        return 'home_list'

    @property
    def state(self):
        """Return the state of the sensor."""
        f = open(file2)
        file = f.read()
        f.close()
        if not file:
            fstate = 'empty'
            homeliston.state = 'off'
        else:
            fstate = file
            homeliston.state = 'on'
             
        return fstate

this creates 4 sensors
sensor.home_list
sensor.home_liston
sensor.store_list
sensor.store_liston
the first of each pair contains the list to use in notify if you want to send it to your phone
and the second is a binary state to use in automations so you only get notified while its populated.

I can now use these to trigger when crossing the zones home and store
I set up several zones called store so no matter which way I come home I will get a reminder

it still needs work but at lease its functional.

1 Like

should mention that it will continue to notify even if all items are checked off. for now you will need to delete items off the list untill there are none left to set the _liston to off

as I said Im still learning so when I can find a way to parse the file for only unchecked items I will post that here.

well that was quick

added some code so now it only adds the unchecked items in your list to the state. you can just check off items without deleting them. They will remain in your phone app as checked but wont show up in hass.

updated code here

from homeassistant.helpers.entity import Entity
file1 = '/Users/dauth/Dropbox/Apps/TaskAgent/Store.txt'
file2 = '/Users/dauth/Dropbox/Apps/TaskAgent/Home.txt'
file3 = '/Users/dauth/Dropbox/Apps/TaskAgent/Work.txt'
file4 = '/Users/dauth/Dropbox/Apps/TaskAgent/Bank.txt'

def setup_platform(hass, config, add_devices, discovery_info=None):
    """Setup the sensor platform."""
    add_devices([storelist()]) 
    add_devices([storeliston()])
    add_devices([homelist()]) 
    add_devices([homeliston()])
    
class storeliston(Entity):
    """Representation of a Sensor."""

    @property
    def name(self):
        """Return the name of the sensor."""
        return 'store_liston'

    @property
    def state(self):
        """Return the state of the sensor."""
        
        return None

    


class storelist(Entity):
    """Representation of a Sensor."""

    @property
    def name(self):
        """Return the name of the sensor."""
        return 'store_list'

    @property
    def state(self):
        """Return the state of the sensor."""
        file = ''
        f = open(file1)
        for line in f:
            s = line[0:1]
            if s == '-':
                file = file+line
        f.close()
        if not file:
            fstate = 'empty'
            storeliston.state = 'off'
        else:
            fstate = file
            storeliston.state = 'on'
             
        return fstate

class homeliston(Entity):
    """Representation of a Sensor."""

    @property
    def name(self):
        """Return the name of the sensor."""
        return 'home_liston'

    @property
    def state(self):
        """Return the state of the sensor."""
        
        return None


    


class homelist(Entity):
    """Representation of a Sensor."""

    @property
    def name(self):
        """Return the name of the sensor."""
        return 'home_list'

    @property
    def state(self):
        """Return the state of the sensor."""
        file = ''
        f = open(file2)
        for line in f:
            s = line[0:1]
            if s == '-':
                file = file+line
        f.close()
        if not file:
            fstate = 'empty'
            homeliston.state = 'off'
        else:
            fstate = file
            homeliston.state = 'on'
             
        return fstate
1 Like

I was looking to do this very thing and was trying to work out an approach; thought it would be a great idea for reminders when I was near a store or something - thanks for posting this. I’ll have to try this out!

1 Like

thanks.

from the structure it shouldn’t be difficult to add more lists. basically just duplicate parts of the code making sure to change the appropriate lines.

I know its not very efficient. There must be a way to do it with much less code but I have a hard time understanding programming. I just grab snips of code off the web and mash them together until it works. LOL

well after getting my automation working I though I should post an example here
sensor:
- platform: reminders

automation:
  hide_entity: True
  trigger:
    platform: state
    entity_id: device_tracker.b14a2d0a679740268c0ea7c24a5675ea
    to: 'store'
  condition:
    condition: state
    entity_id: 'sensor.store_liston'
    state: 'on'
  action:
    service: notify.Jarvis
    data_template:
      message: "From jarvis"
      title: "{{ states.sensor.store_list.state}}"

just duplicate and change the word ‘store’ to reflect the list you want to reference.

2 Likes