Insteon Thermostat Monitoring & Control through ISY-994i

Note: This is only for folks who have the Universal Devices ISY-994i controller. This also works for z-wave thermostats connected to the ISY, with the small modification that you do not multiply the desired temperature by 2 when using the ISY REST API to set the desired temperature.

The problem: No native HA support for the Insteon thermostat.

The solution: Use command line sensors and scripts to extract thermostat data to interact with the ISY-994i REST API. Thanks to this thread I was able to figure out how to use grep commands to pull out the thermostat data from the XML result from the ISY REST API.

The first thing you need to do is find out the node ID for your thermostat; to do that, go to http://ISYipaddress/rest/nodes and search this list for “thermostat”. You should find a 7 digit node address that corresponds to the thermostat. You will need to use that node address for all of these rest commands (include spaces exactly as written in the node address!!). When you enter the address into the URL field, the browser will reformat the node address into a variation where it replaces the spaces with %20; this format is it how I entered the URL into my config files. I haven’t tried using spaces in the URL in the config files, so I can’t say for sure if that would work.

Snip from the REST response to the URL above:
image

Here’s the sensor configuration:

  - platform: command_line
    name: House Temp
    command: '/usr/bin/curl --user ISYusername:ISYpassword "http://ISYipaddress/rest/nodes/ThermostatNodeAddress/ST" 2>&1 | grep -oPm1 "(?<=formatted=\")[0-9.]+"'
    value_template: '{{ value | round(1) }}'
    unit_of_measurement: °F
    scan_interval: 5

  - platform: command_line
    name: House Humidity
    command: '/usr/bin/curl --user ISYusername:ISYpassword "http://ISYipaddress/rest/nodes/ThermostatNodeAddress/CLIHUM" 2>&1 | grep -oPm1 "(?<=formatted=\")[0-9]+"'
    unit_of_measurement: 'percent'
    scan_interval: 5

  - platform: command_line
    name: Heat Setpoint
    command: '/usr/bin/curl --user ISYusername:ISYpassword "http://ISYipaddress/rest/nodes/ThermostatNodeAddress/CLISPH" 2>&1 | grep -oPm1 "(?<=formatted=\")[0-9]+"'
    unit_of_measurement: °F
    scan_interval: 5

  - platform: command_line
    name: Cool Setpoint
    command: '/usr/bin/curl --user ISYusername:ISYpassword "http://ISYipaddress/rest/nodes/ThermostatNodeAddress/CLISPC" 2>&1 | grep -oPm1 "(?<=formatted=\")[0-9]+"'
    unit_of_measurement: °F
    scan_interval: 5

  - platform: command_line
    name: Thermostat Mode
    command: '/usr/bin/curl --user ISYusername:ISYpassword "http://ISYipaddress/rest/nodes/ThermostatNodeAddress/CLIMD" 2>&1 | grep -oPm1 "(?<=formatted=\")[A-Za-z]+"'
    scan_interval: 5

  - platform: command_line
    name: Fan Mode
    command: '/usr/bin/curl --user ISYusername:ISYpassword "http://ISYipaddress/rest/nodes/ThermostatNodeAddress/CLIFS" 2>&1 | grep -oPm1 "(?<=formatted=\")[A-Za-z]+"'
    scan_interval: 5

REST command configuration (uses rest_command component):

  heat_setpoint:
    url: http://ISYipaddress/rest/nodes/ThermostatNodeAddress/set/CLISPH/{{ states.input_number.heat_setpoint.state | int * 2 }}
    username: ISYusername
    password: ISYpassword
  cool_setpoint:
    url: http://ISYipaddress/rest/nodes/ThermostatNodeAddress/set/CLISPC/{{ states.input_number.cool_setpoint.state | int * 2 }}
    username: ISYusername
    password: ISYpassword
  thermostat_mode_off:
    url: http://ISYipaddress/rest/nodes/ThermostatNodeAddress/cmd/CLIMD/0
    username: ISYusername
    password: ISYpassword 
  thermostat_mode_heat:
    url: http://ISYipaddress/rest/nodes/ThermostatNodeAddress/cmd/CLIMD/1
    username: ISYusername
    password: ISYpassword
  thermostat_mode_cool:
    url: http://ISYipaddress/rest/nodes/ThermostatNodeAddress/cmd/CLIMD/2
    username: ISYusername
    password: ISYpassword
  thermostat_mode_auto:
    url: http://ISYipaddress/rest/nodes/ThermostatNodeAddress/cmd/CLIMD/3
    username: ISYusername
    password: ISYpassword
  fan_mode_on:
    url: http://ISYipaddress/rest/nodes/ThermostatNodeAddress/cmd/CLIFS/7
    username: ISYusername
    password: ISYpassword
  fan_mode_auto:
    url: http://ISYipaddress/rest/nodes/ThermostatNodeAddress/cmd/CLIFS/8
    username: ISYusername
    password: ISYpassword

Input numbers (sliders) used to control the heat and cool setpoints:

input_number:
  heat_setpoint:
    name: Heat Setpoint
    min: 58
    max: 72
    mode: box
    icon: mdi:thermometer
    unit_of_measurement: °F
  cool_setpoint:
    name: Cool Setpoint
    min: 72
    max: 80
    mode: box
    icon: mdi:thermometer
    unit_of_measurement: °F

Input select for thermostat mode and fan mode:

input_select:
  thermostat_mode:
    name: Thermostat Mode
    options:
      - Auto
      - Heat
      - Cool
      - "Off"
    icon: mdi:gauge
  fan_mode:
    name: Fan Mode
    options:
      - Auto
      - "On"
    icon: mdi:fan

Automations to use input selects and input numbers to control the thermostat:

- action:
    service: rest_command.thermostat_mode_heat
  alias: Set Thermostat Mode to Heat
  id: '4'
  trigger:
    platform: state
    entity_id: input_select.thermostat_mode
    to: "Heat"

- action:
    service: rest_command.thermostat_mode_cool
  alias: Set Thermostat Mode to Cool
  id: '5'
  trigger:
    platform: state
    entity_id: input_select.thermostat_mode
    to: "Cool"

- action:
    service: rest_command.thermostat_mode_auto
  alias: Set Thermostat Mode to Auto
  id: '9'
  trigger:
    platform: state
    entity_id: input_select.thermostat_mode
    to: "Auto"

- action:
    service: rest_command.thermostat_mode_off
  alias: Set Thermostat Mode to Off
  id: '6'
  trigger:
    platform: state
    entity_id: input_select.thermostat_mode
    to: "Off"

- action:
    service: rest_command.fan_mode_auto
  alias: Set Fan Mode to Auto
  id: '7'
  trigger:
    platform: state
    entity_id: input_select.fan_mode
    to: "Auto"

- action:
    service: rest_command.fan_mode_on
  alias: Set Fan Mode to On
  id: '8'
  trigger:
    platform: state
    entity_id: input_select.fan_mode
    to: "On"

- id: Heat Setpoint
  alias: Heat Setpoint Slider
  trigger:
    platform: state
    entity_id: input_number.heat_setpoint
  action:
    service: rest_command.heat_setpoint

- id: Cool Setpoint
  alias: Cool Setpoint Slider
  trigger:
    platform: state
    entity_id: input_number.cool_setpoint
  action:
    service: rest_command.cool_setpoint

Automations to update the setpoints, thermostat mode, and fan modes so that the communication is bi-directional (if the thermostat is manually changed, it will update in Home Assistant) Thanks to @xstrex for helping with this.

- id: Thermostat Mode Update
  alias: Thermostat Mode Update
  trigger:
    platform: state
    entity_id: sensor.thermostat_mode
  action:
  - service: input_select.select_option
    data_template:
      entity_id: input_select.thermostat_mode
      option: >
        {{ states.sensor.thermostat_mode.state }}

- id: Fan Mode Update
  alias: Fan Mode Update
  trigger:
    platform: state
    entity_id: sensor.fan_mode
  action:
  - service: input_select.select_option
    data_template:
      entity_id: input_select.fan_mode
      option: >
        {{ states.sensor.fan_mode.state }}

- id: Heat Setpoint Update
  alias: Heat Setpoint Update
  trigger:
    platform: state
    entity_id: sensor.heat_setpoint
  action:
  - service: input_number.set_value
    data_template:
      entity_id: input_number.heat_setpoint
      value: >
        {{ states.sensor.heat_setpoint.state }}

- id: Cool Setpoint Update
  alias: Cool Setpoint Update
  trigger:
    platform: state
    entity_id: sensor.cool_setpoint
  action:
  - service: input_number.set_value
    data_template:
      entity_id: input_number.cool_setpoint
      value: >
        {{ states.sensor.cool_setpoint.state }}

Add your sensors, input numbers, and input select buttons to your user interface, and you’re all set. The photo below is my HVAC group. The heat and AC switches on the bottom are “lights” that are automatically brought over from ISY, and they correspond to whether the heat or AC is on or off.

This is not an elegant way to get thermostat monitoring and control in HA, but it’s all I could figure out until there is native support for Insteon thermostats.

See xstrex’s post #11 for how to implement home/away setpoints with presence detection.

4 Likes

Thanks for posting this! I’ve got mostly Insteon devices, all controlled via an ISY994(iz), and have been trying to figure out if the insteon thermostat could work with HA. Does this setup work fairly well?

Does HA recgonize any of the devices the ISY creates for the thermostat? I’d assume it would see the sensors and switches associated with the thermostat.

That’s too bad that we’re stuck using the command line component to control a thermostat connected to a supported smart-home hub.

The setup works as well as you would expect given that it’s a workaround. The setpoint sensor value takes a few seconds to update when you increase or decrease, because it has to go through a few steps.

HA recognizes the Heat and AC binary sensors that are on when the heat/ac is calling for heat/cooling; however, they get imported from ISY as “lights” even though they are just binary sensors. Those are the two switches at the very bottom of the image in my previous post.

Thanks for the details write-up, I’ve used it to get my thermostat added to HA. Though for some reason, my setpoint_up & setpoint_down aren’t working quite right, even though the command returns a 200, in the browser. It isn’t actually changing the set point in the ISY admin interface.

Here’s my commands:

  thermostat_up:
    url: http://[redacted]/rest/nodes/ZW003_1/cmd/BRT
    username: [redacted]
    password: [redacted]
  thermostat_down:
    url: http://[redacted]/rest/nodes/ZW003_1/cmd/DIM
    username: [redacted]
    password: [redacted]

While adding this, it got me thinking. I bet we could add an input slider to the temperature setpoint, just not sure how yet.
Thanks, again!

Glad to hear you got it going; I’m not sure why the setpoint commands aren’t working. I definitely agree an input slider for the setpoint would be much nicer! Let me know if you get it working.

I did add these automations, seemed silly to me to have a sensor and an input_select for the same things:

- id: Climate Mode Update
  alias: Climate Mode Update
  trigger:
    platform: state
    entity_id: sensor.thermostat_mode
  action:
  - service: input_select.select_option
    data_template:
      entity_id: input_select.thermostat_mode
      option: >
        {{ states.sensor.thermostat_mode.state }}

- id: Climate Fan Mode Update
  alias: Climate Fan Mode Update
  trigger:
    platform: state
    entity_id: sensor.fan_mode
  action:
  - service: input_select.select_option
    data_template:
      entity_id: input_select.fan_mode
      option: >
        {{ states.sensor.fan_mode.state }}

So now when the sensor for thermostat_mode & fan_mode change, it updates the input_select, respectively.

Eureka! /rest/nodes/<node>/set/<property>/<value>

Got input sliders (input_number) all added, and everything works just as you’d expect. the input_select’s update based on current state. Adjusting a slider changes the set_point, and applies it to the the ISY, thus adjusting the temperature. All modes seem to work. Here’s what it looks like:

@xstrex Nice work! This is exactly what I was hoping to eventually do. Can you share your code for having the input sliders call the rest commands? I assume that you’re able to just use the value assigned by the input_number and inserting that in the < value > section of the rest command?

Thanks @DetroitEE, yea that’s exactly how it worked out. I’m in the process of adding a few more sliders, to adjust the temperature based on home/away, once that’s working, I’ll post everything. Please stand-by.

1 Like

Alright, as promised, here’s all the configs:

Rest Commands:

  heat_setpoint:
      url: http://[redacted]/rest/nodes/[redacted]/set/CLISPH/{{ states.input_number.heat_setpoint.state | int }}
      username: [redacted]
      password: [redacted]

  cool_setpoint:
      url: http://[redacted]/rest/nodes/[redacted]/set/CLISPC/{{ states.input_number.cool_setpoint.state | int }}
      username: [redacted]
      password: [redacted]

  thermostat_mode_off:
    url: http://[redacted]/rest/nodes/[redacted]/cmd/CLIMD/0
    username: [redacted]
    password: [redacted]

  thermostat_mode_heat:
    url: http://[redacted]/rest/nodes/[redacted]/cmd/CLIMD/1
    username: [redacted]
    password: [redacted]

  thermostat_mode_cool:
    url: http://[redacted]/rest/nodes/[redacted]/cmd/CLIMD/2
    username: [redacted]
    password: [redacted]

  thermostat_mode_auto:
    url: http://[redacted]/rest/nodes/[redacted]/cmd/CLIMD/3
    username: [redacted]
    password: [redacted]

  fan_mode_on:
    url: http://[redacted]/rest/nodes/[redacted]/cmd/CLIFS/7
    username: [redacted]
    password: [redacted]

  fan_mode_auto:
    url: http://[redacted]/rest/nodes/[redacted]/cmd/CLIFS/8
    username: [redacted]
    password: [redacted]

Input_Number (set your “initial” value below, for temps suitable in your area):

  heat_setpoint:
    name: 'Heat Setpoint'
    min: 50
    max: 90
    step: 1
    initial: 75

  cool_setpoint:
    name: "Cool Setpoint"
    min: 50
    max: 90
    step: 1
    initial: 72

  home_heat_setpoint:
    name: 'Home Heat Setpoint'
    min: 50
    max: 90
    step: 1
    initial: 75

  away_heat_setpoint:
      name: 'Away Heat Setpoint'
      min: 50
      max: 90
      step: 1
      initial: 65

  home_cool_setpoint:
    name: "Home Cool Setpoint"
    min: 50
    max: 90
    step: 1
    initial: 78

  away_cool_setpoint:
    name: "Away Cool Setpoint"
    min: 50
    max: 90
    step: 1
    initial: 82

Automations:

- id: Climate Mode Heat
  alias: Climate Mode Heat
  trigger:
    platform: state
    entity_id: input_select.thermostat_mode
    to: "Heat"
  action:
    service: rest_command.thermostat_mode_heat

- id: Climate Mode Cool
  alias: Climate Mode Cool
  trigger:
    platform: state
    entity_id: input_select.thermostat_mode
    to: "Cool"
  action:
    service: rest_command.thermostat_mode_cool

- id: Climate Mode Auto
  alias: Climate Mode Auto
  trigger:
    platform: state
    entity_id: input_select.thermostat_mode
    to: "Auto"
  action:
    service: rest_command.thermostat_mode_auto

- id: Climate Mode Off
  alias: Climate Mode Off
  trigger:
    platform: state
    entity_id: input_select.thermostat_mode
    to: "Off"
  action:
    service: rest_command.thermostat_mode_off

- id: Climate Fan Mode Auto
  alias: Climate Fan Mode Auto
  trigger:
    platform: state
    entity_id: input_select.fan_mode
    to: "Auto"
  action:
    service: rest_command.fan_mode_auto

- id: Climate Fan Mode On
  alias: Climate Fan Mode On
  trigger:
    platform: state
    entity_id: input_select.fan_mode
    to: "On"
  action:
    service: rest_command.fan_mode_on

- id: Climate Mode Update
  alias: Climate Mode Update
  trigger:
    platform: state
    entity_id: sensor.thermostat_mode
  action:
    service: input_select.select_option
    data_template:
      entity_id: input_select.thermostat_mode
      option: >
        {{ states.sensor.thermostat_mode.state }}

- id: Climate Fan Mode Update
  alias: Climate Fan Mode Update
  trigger:
    platform: state
    entity_id: sensor.fan_mode
  action:
    service: input_select.select_option
    data_template:
      entity_id: input_select.fan_mode
      option: >
        {{ states.sensor.fan_mode.state }}

- id: Heat Setpoint
  alias: Heat Setpoint Slider
  trigger:
    platform: state
    entity_id: input_number.heat_setpoint
  action:
    service: rest_command.heat_setpoint

- id: Cool Setpoint
  alias: Cool Setpoint Slider
  trigger:
    platform: state
    entity_id: input_number.cool_setpoint
  action:
    service: rest_command.cool_setpoint

- id: Home Heat
  alias: Home Heat
  trigger:
    platform: state
    entity_id: group.presence
    from: not_home
    to: home
  condition:
    condition: state
    entity_id: sensor.thermostat_mode
    state: "Heat"
  action:
    service: homeassistant.turn_on
    entity_id: script.home_heat

- id: Away Heat
  alias: Away Heat
  trigger:
    platform: state
    entity_id: group.presence
    from: home
    to: not_home
  condition:
    condition: state
    entity_id: sensor.thermostat_mode
    state: "Heat"
  action:
    service: homeassistant.turn_on
    entity_id: script.away_heat

- id: Home Cool
  alias: Home Cool
  trigger:
    platform: state
    entity_id: group.presence
    from: not_home
    to: home
  condition:
    condition: state
    entity_id: sensor.thermostat_mode
    state: "Cool"
  action:
    service: homeassistant.turn_on
    entity_id: script.home_cool

- id: Away Cool
  alias: Away Cool
  trigger:
    platform: state
    entity_id: group.presence
    from: home
    to: not_home
  condition:
    condition: state
    entity_id: sensor.thermostat_mode
    state: "Cool"
  action:
    service: homeassistant.turn_on
    entity_id: script.away_cool

Scripts:

# Climate Scripts
  home_heat:
    alias: 'Home Heat'
    sequence:
      - service: input_number.set_value
        data_template:
          entity_id: input_number.heat_setpoint
          data:
            value: >
              {{ states.input_number.home_heat_setpoint.state | int }}

  away_heat:
    alias: 'Away Heat'
    sequence:
      - service: input_number.set_value
        data_template:
          entity_id: input_number.heat_setpoint
          data:
            value: >
              {{ states.input_number.away_heat_setpoint.state | int }}

  home_cool:
    alias: 'Home Cool'
    sequence:
      - service: input_number.set_value
        data_template:
          entity_id: input_number.cool_setpoint
          data:
            value: >
              {{ states.input_number.home_cool_setpoint.state | int }}

  away_cool:
    alias: 'Away Cool'
    sequence:
      - service: input_number.set_value
        data_template:
          entity_id: input_number.cool_setpoint
          data:
            value: >
              {{ states.input_number.away_cool_setpoint.state | int }}

Input_Select:

  thermostat_mode:
    name: Thermostat Mode
    options:
      - Auto
      - Heat
      - Cool
      - "Off"
    icon: mdi:gauge

  fan_mode:
    name: Fan Mode
    options:
      - Auto
      - "On"
    icon: mdi:fan

Sensors:

  - platform: command_line
    name: House Temp
    command: '/usr/bin/curl --user [redacted]:[redacted] "http://[redacted]/rest/nodes/[redacted]/ST" 2>&1 | grep -oPm1 "(?<=formatted=\")[0-9]+"'
    unit_of_measurement: °F
    scan_interval: 5

  - platform: command_line
    name: Heat Setpoint
    command: '/usr/bin/curl --user [redacted]:[redacted] "http://[redacted]/rest/nodes/[redacted]/CLISPH" 2>&1 | grep -oPm1 "(?<=formatted=\")[0-9]+"'
    unit_of_measurement: °F
    scan_interval: 5

  - platform: command_line
    name: Cool Setpoint
    command: '/usr/bin/curl --user [redacted]:[redacted] "http://[redacted]/rest/nodes/[redacted]/CLISPC" 2>&1 | grep -oPm1 "(?<=formatted=\")[0-9]+"'
    unit_of_measurement: °F
    scan_interval: 5

  - platform: command_line
    name: Thermostat State
    command: '/usr/bin/curl --user [redacted]:[redacted] "http://[redacted]/rest/nodes/[redacted]/CLIHCS" 2>&1 | grep -oPm1 "(?<=formatted=\")[A-Za-z]+"'
    scan_interval: 5

  - platform: command_line
    name: Fan State
    command: '/usr/bin/curl --user [redacted]:[redacted] "http://[redacted]/rest/nodes/[redacted]/CLIFRS" 2>&1 | grep -oPm1 "(?<=formatted=\")[A-Za-z]+"'
    scan_interval: 5

  - platform: command_line
    name: Thermostat Battery Level
    command: '/usr/bin/curl --user [redacted]:[redacted] "http://[redacted]/rest/nodes/[redacted]/BATLVL" 2>&1 | grep -oPm1 "(?<=formatted=\")[0-9]+"'
    unit_of_measurement: '%'
    scan_interval: 5

  - platform: command_line
    name: Thermostat Mode
    command: '/usr/bin/curl --user [redacted]:[redacted] "http://[redacted]/rest/nodes/[redacted]/CLIMD" 2>&1 | grep -oPm1 "(?<=formatted=\")[A-Za-z]+"'
    scan_interval: 5

  - platform: command_line
    name: Fan Mode
    command: '/usr/bin/curl --user [redacted]:[redacted] "http://[redacted]/rest/nodes/[redacted]/CLIFS" 2>&1 | grep -oPm1 "(?<=formatted=\")[A-Za-z]+"'
    scan_interval: 5

  - platform: template
    sensors:
      home_heat_setpoint:
        friendly_name: "Home Heat Setpoint"
        unit_of_measurement: '°F'
        value_template: "{{ states.input_number.home_heat_setpoint.state | int }}"
      away_heat_setpoint:
        friendly_name: "Away Heat Setpoint"
        unit_of_measurement: '°F'
        value_template: "{{ states.input_number.away_heat_setpoint.state | int }}"
      home_cool_setpoint:
        friendly_name: "Home Cool Setpoint"
        unit_of_measurement: '°F'
        value_template: "{{ states.input_number.home_cool_setpoint.state | int }}"
      away_cool_setpoint:
        friendly_name: "Away Cool Setpoint"
        unit_of_measurement: '°F'
        value_template: "{{ states.input_number.away_cool_setpoint.state | int }}"

Screenshot:

Todo:
Add template sensor to show current value of home_heat_setpoint, away_heat_setpoint, home_cool_setpoint & away_cool_setpoint. EDIT DONE! See above template sensors in sensors config.

EDTI 2: For some reason my scripts above aren’t working the way they should, need to figure out why.

EDIT 3: This might work, my script formatting might of been a bit off. (putting it here since I can’t implement / test it at this time):

  home_heat:
    alias: 'Home Heat'
    sequence:
    - service: input_number.set_value
      data_template:
        entity_id: input_number.heat_setpoint
        value: >
          {{ states.input_number.home_heat_setpoint.state | int }}

@xstrex Great stuff, thanks for sharing your whole setup. I plan on editing my original post to include some of these improvements, as this is much better than my setpoint up/down scripts. I don’t need so many sliders, I just implemented heat and cool setpoints. Also, I set the slider type to “box” instead of slider, which actually still gives you a slider, but also displays the value to the right of the slider. This enabled me to delete the separate sensor lines for the heat and cool setpoints.

A note to anyone using Insteon thermostats, you have to multiply the setpoint temperature *2 when issuing the rest commands to CLISPH and CLISPC. For example, the rest url for setting the heat setpoint to 70 degrees would be:

http://[redacted]/rest/nodes/[redacted]/set/CLISPH/{{ states.input_number.heat_setpoint.state | int * 2 }}

Thanks for the “box” mode, I wasn’t aware of that, I like that a lot better than having a separate sensor just to display the value of the setpoint. I’ll implement that tonight.

OK, I’ve edited the original post to include the “new and improved” version with bi-directional communication sliders and input selects. Thanks @xstrex for all the help.

As much of a pain as it was to get it to this point, it works quite well once it’s setup.

1 Like

I am first time HA user but long time ISY99 user. Can you help me to intregration of the ISY994i module so I can control lights in my house. I need simple steps instructions. I contact ISY snd UDI tech supports but no help. Thanks!

@MrTeaIOT Add the ISY component to your HA yaml configuration file. When you reboot, if the settings are correct, it will automatically import all of your lights from ISY to HA. Follow the instructions here:

Updated the code in the original post to extract the house temperature value to 1 decimal point. The changes are as follows:

Added a . after the 9 in the [0-9] section of the grep command; this tells grep to include the decimal point and the numbers behind it.

Added the value_template: '{{ value | round(1) }}' line to the house temperature sensor in order to round the extracted value to 1 decimal point. Without this, it will extract the value to two decimal points, but the second decimal point is useless since the Insteon thermostat only reads in half degree increments.

I’m trying to make this work for my z-wave thermostat connected to ISY. The . in the [0-9] section of the GREP command above does not work for me. Also, the GREP command does not like the -P option. What is it supposed to do? Can someone explain this command: grep -oPm1 “(?<=formatted=”)[0-9]+"

After some research, I was able to find that the -P option is only available in some improved version of grep, such as GNU grep. This option will enable Perl-like regex. Well, that does not work within HASSIO. Can anyone tell me what would be the regular expression that would be equivalent to

GREP -oPm1 "(?<=formatted=\")[0-9]+"

? I have tried all kinds of combinations, to no avail.

Thanks!

@Madelinot It’s possible that the Z-wave thermostat value is an integer, and does not have a decimal point value, maybe that’s why the . is not working. Can you post the full REST response from the ISY? The ISY also returns a parameter called "value’, and I’m curious if that is an integer as well.

This page is an excellent resource for understanding grep. I still don’t totally understand all of it, as I based these commands on a previous example and modified it to do what I needed.

-P tells grep to use Perl regular expressions. I’m not sure why that’s needed here, but it’s worked for me and so I never bothered to look at an alternative method. Are you using a Raspberry Pi?

See the link for an explanation of the other options (o & m1).

?<= is a positive lookbehind assertion. This tells grep to match everything after the text formatted=" . The number range listed in the square brackets tell grep to only match numbers. The + is a repetition operator which matches at least 1 digit. This could be replaced with {2} if you want it to only match 2 digits, {4} for 4 digits, {2,} for at least 2 digits, {2,4} for at least 2 digits and at most 4 digits.