Giter Club home page Giter Club logo

extract_entity's Introduction

with thanks to the inspriation https://github.com/sunnythaper/python_scripts

extract_entity.py

OVERVIEW

This script allows you to export your current entity states/attributes into a file!

  • original idea is to use the extracted data for later reference, e.g. compare forecast of yesterday with actual of today
  • extracted file contains lines related to 'notify', see below and needs to be cleaned before import into sensor

EXAMPLE JSON

{
    "entity": ["weather.home"],
    "attributes": ["forecast"],
    "save_file": true
}

or as a service

service: python_script.extract_entity
data:
  entity: weather.forecast_home
  attributes:
    - forecast
  save_file: true

FILE SAVING

The script can save directly to a file in the HASS configuration directory, simply add a file notification declaration exactly as below. The file name is referenced by the script, so do not change the script name. You may change the filename to whatever you wish, however.

notify:
  - name: json_file_generator
    platform: file
    filename: generated_extract.json
    timestamp: false 

Read file back in HA Remove first two lines from "generated_extract.json", they contain data generated by the Notification process: 'Assistant' and '---'

grep -vE "Assistant|----" generated_json.yaml

Example import

sensor:
  - platform: command_line
    name: forecast_home
    scan_interval: 30000
    command: >
          echo "$( grep -vE "Assistant|----" generated_extract.json | jq '.' ) " 
    value_template: "OK"
    json_attributes:
        - forecast 

extract_entity's People

Contributors

vingerha avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.